Tutorial Archives - Matthew Gove Blog https://blog.matthewgove.com/tag/tutorial/ Travel the World through Maps, Data, and Photography Sat, 02 Jul 2022 15:23:31 +0000 en-US hourly 1 https://wordpress.org/?v=6.1.6 https://blog.matthewgove.com/wp-content/uploads/2021/03/cropped-android-chrome-512x512-1-32x32.png Tutorial Archives - Matthew Gove Blog https://blog.matthewgove.com/tag/tutorial/ 32 32 How to Create a Custom Map in Adobe Illustrator https://blog.matthewgove.com/2022/06/10/how-to-create-a-custom-map-in-adobe-illustrator/ Fri, 10 Jun 2022 15:00:00 +0000 https://blog.matthewgove.com/?p=4781 Custom, branded maps are one of the best ways you can stand out from your competition, especially in the world of travel and content creation. With so many people, groups, and organizations still relying on products like Google Maps, you’ll not only stand out from the crowd, but also come […]

The post How to Create a Custom Map in Adobe Illustrator appeared first on Matthew Gove Blog.

]]>
Custom, branded maps are one of the best ways you can stand out from your competition, especially in the world of travel and content creation. With so many people, groups, and organizations still relying on products like Google Maps, you’ll not only stand out from the crowd, but also come across as way more professional. And Adobe Illustrator makes it incredibly easy to create a custom map for your next video, presentation, or any other type of content.

Last time, you learned how to import GIS shapefiles into Adobe Illustrator. Today, you’re going to use those imported shapefiles to create a custom map in Adobe Illustrator.

Where We Left Off Last Time: Importing GIS Shapefiles into Adobe Illustrator

In the previous tutorial, we began the process of creating custom maps in Adobe Illustrator. That tutorial focused on importing GIS shapefiles into Adobe Illustrator, which consisted of several steps.

  1. Load several shapefiles into QGIS to create vector outlines
  2. Export those vector outlines from QGIS into SVG Format
  3. Import the SVG Map into Adobe Illustrator
  4. Scale and Position the Map to Fill our Illustrator workspace

What We’re Going to Learn Today: Finishing Your Custom Map in Adobe Illustrator

Today, we’re going to finish the process of creating a custom map in Adobe Illustrator. In this tutorial, you’ll learn how to do the following:

  • Extract parts of the vector and sort them into layers
  • Add titles, labels, and the background imagery
  • Set up your map for animation

At the end of the day, you’ll wind up with a beautiful final map product that looks like this:

1. Extract Your Custom Map Features from the SVG File in Adobe Illustrator

To make it easier to manage your custom map assets in Adobe Illustrator, put each feature (or group of features) into their own layers. We covered this briefly in the previous tutorial, but I want to go over it in much more detail. First, let’s recall where we left off. We had just imported the SVG (vector image) file into Adobe Illustrator using File > Place.

Shapefile Features Loaded into Adobe Illustrator from an SVG Vector Image File

Before we do anything in Illustrator, make a list of the features you will be extracting from the SVG file. For the Utah National Parks, we want to extract the following:

  • The Utah State Boundary
  • Zion National Park Outline
  • Bryce Canyon National Park Outline
  • Capitol Reef National Park Outline
  • Canyonlands National Park Outline
  • Arches National Park Outline

If it helps, you can also make a list of everything you want to exclude from the final map. For our map of the Utah National Parks, we only need to exclude the rectangle that bounds the SVG image, which is outlined in blue in the above screenshot. Don’t worry about colors at this point. We’ll address them shortly.

Scale and Position Your Custom Map in Adobe Illustrator Before Extracting Any Features

Before you extract any features from the imported SVG file, I highly recommend that you scale your custom map and move it into its final position on the Adobe Illustrator artboard. You can always make minor to its position and scale as you go. However, it’s much easier to do any major moving and scaling while it’s still just a single entity.

To scale the SVG file in Illustrator, simply grab any of the anchor points on the corner or side of the SVG file and drag it to its desired size. To prevent image distortion, hold the Shift key down as you scale it, which maintains the original aspect ratio.

The green rectangles in Illustrator mark the boundaries of your artboard, so scale it to fill as much of the artboard as possible. If you need to scale the SVG beyond the boundaries of the Adobe Illustrator, that’s perfectly fine. Illustrator will crop everything to fit the artboard when you go to export it.

Additionally, make sure that you leave room for any titles, subtitles, and labels you’ll be adding to the map later. You should also center the map horizontally in the frame. Your scaled and centered custom map of Utah should look something like this in Adobe Illustrator.

Scaled and Centered Shapefile/SVG Features in Adobe Illustrator

Extract Each Feature of Your Custom Map into Its Own Layer in Adobe Illustrator

On the initial extraction, you should put each feature into its own layer in Illustrator. We do this for two reasons.

  1. It best sets the map up for animation
  2. It’s much easier to merge multiple layers into one than it is to separate one layer in several.

To begin your feature extraction, first open the Layers panel. Click on the carat to reveal the components of the SVG layer.

Expanded Layers Circled in Red on the Right Hand Side of the Main Adobe Illustrator Window

Despite there being so many components, the features you want to extract are only going to be in a small subset of those components. The easiest way to find your map features is to click on the eyeball next to each component in the layers panel. If your feature disappears from the map, that’s the component you need to extract.

To extract the component you’ve identified, create a new layer to put it in. Don’t worry about the order of layers for now. The new layer button is in the bottom right corner of the main Adobe Illustrator window. Give it an easily identifiable name, such as “Zion Boundary” or “Canyonlands Outline”.

The New Layer Button in Adobe Illustrator

Click and drag the component from the original SVG file to the layer you just created. You should see the feature now listed under the new layer. Do note that your feature may be divided into several components in the SVG layer. In that case, drag each component of your feature to your new layer.

To confirm everything copied correctly, click the eyeball to show and hide your new layer. Your feature should disappear from and reappear on the map.

Outline of the Utah State Border and Zion National Park Extracted From the SVG File

Finally, repeat the process for each feature you will be putting on your final map. Once everything is extracted into their own layers, you can hide or delete the original SVG layer. We will not be using it anymore.

A Note on Dealing with Complex Features

If you have a complex feature you are trying to extract or if two features you want on your map are combined into a single component of the SVG file, you can still extract them. Use Illustrator’s Eraser tool to delete any unwanted parts of the SVG components. You can separate multiple features from a single SVG component with Illustrator’s Direct Selection Tool. Please consult the Adobe Illustrator documentation for more details.

2. Add a Background Image

Next up, we’ll add the background image. In our Utah National Parks map, the background image is of the hoodoos at Bryce Canyon from my trip in 2017. Your background image should be a high enough resolution to fill the artboard of your Adobe Illustrator project. Remember that while Illustrator is a vector editing program, your images still consist of pixels. If you scale them up beyond their full resolution, they will become pixelated and grainy.

Before you add your background image, though, you will need to do a couple things. These are both optional, but I highly recommend doing them.

  1. Crop your image to match the aspect ratio of your artboard in Adobe Illustrator. For videos, that aspect ratio is 16:9. I do this mainly for my own sanity so I don’t accidentally put features outside of the artboard boundaries that will get clipped off.
  2. If you plan to use a background overlay that’s any color other than black or white, make your image black and white. Colored overlays can do wonky things to the colors of your image, often with undesirable results. If you’re using your own branding, black and white images help ensure that the map stays the recognizable colors of your brand.

Use Illustrator’s File > Place function to embed your background image into Illustrator. The features you imported in the previous step may disappear from view, but don’t worry. They’re just underneath the image. We’ll correct that shortly. Then, drag each corner of the image to the corners of your artboard to fill it.

Don’t panic if other features disappear when you load the background image. They’re just underneath the picture.

3. Add a Background Overlay

A background overlay is a solid color, semi-transparent overlay that goes on top of your background image. Its primary purpose is to make the content of your map easier to read. Not only does it increase the contrast, but it also makes the background image much more subtle. Remember, you want your viewers’ eyes to be drawn to the content, not to the background image.

Use the slider below to see the difference between having a background overlay vs having nothing. The difference in readability is night and day.

Background Overlay Setup in Adobe Illustrator

You should put the background overlay either in the same layer as your background image or in its own layer. The easiest way to add the background overlay is with Illustrator’s Rectangle Tool.

Location of Illustrator’s Rectangle Tool in the Toolbar

After creating the rectangle in Illustrator, drag the corners so the rectangle fills the artboard.

The Background Overlay will not look terribly exciting when you first load it.

Background Overlay Color and Opacity

Your background overlay should never be anything besides a single color. It will be too distracting otherwise. If you want to use a secondary color, make the text and content of your map that color. Remember, color can be very powerful for invoking emotions in your audience. Use it wisely.

So what color should you make your background overlay? I recommend one of three options.

  1. Your Primary Brand Color
  2. Black
  3. White

Unless you want to put more emphasis on your background image, you should use your primary brand color for the background overlay. For example, Coca-Cola would use red, UPS would brown, and John Deere would use green.

Start with the opacity set at 75 to 85%, and adjust it as needed. You should be able to see your background image through the overlay and be able to immediately recognize what it is. However, you don’t want the background image to distract from the content on your map.

The background image subtly shows through the background overlay that’s set to 80% opacity

Interestingly, you may have a situation where you want to emphasize the background image a little more. It comes up more often than you’d think. I use it on the title screens of pretty much all of my videos.

In that case, you should use a black or white background overlay, and set the opacity to 30 to 50% to start. Like before, you’ll need to adjust it as necessary. I also recommend using a color background photo, because the black or white overlay won’t distort the colors of your image.

Example of a Black Background Overlay Set to 40% Opacity from Our Arches and Canyonlands Video

4. Add Any and All Map Titles, Subtitles, Labels, and Branding

The final elements to add are the title, labels, and branding. Like the background overlay, most of these should go either in the same layer as the background image and/or overlay, or in their own layer. However, there is one distinct exception. All feature labels should go in the same layer as the feature itself, or in their own layer. If you plan to animate the feature labels independently of the features themselves, each label must go in its own layer.

Use the text tool in Adobe Illustrator to add text to your custom map. Set the font to either match your brand fonts, which I highly recommend, or, to an easy-to-read font. The last thing you want is your viewers struggling to read the beautiful map you put such effort into.

Title text and Branding on our Utah National Parks map. We labeled the features, but you can’t see them because they’re still underneath the background image.

5. Arrange the Layers in the Correct Order

Now that we’ve got all of the elements of our map in place, it’s time to put the layers into the correct order so you can see all of your features. If you’re not familiar with the concept of layers, it’s very similar to making a sandwich. For example, the layers of a ham sandwich, from top to bottom, would be something like this:

  • Bread
  • Mayo/Mustard
  • Cheese
  • Veggies
  • Ham
  • Mayo/Mustard
  • Bread

Likewise, we can arrange the layers of our map in a similar order. From top to bottom, the layers of our map are as follows.

  • Features and Feature Labels (unless they overlap, the order of each individual feature layer does not matter)
  • Titles, Subtitles, Labels, and Branding
  • Background Overlay
  • Background Image

To rearrange the order of your custom map layers in Adobe Illustrator, open the Layers panel. Then, all you have to do is click and drag the layers into the correct order. Make sure you don’t accidentally put one layer into another. However, if you do, a Ctrl/Cmd-Z is all it takes to undo your mistake.

Utah National Parks Map with Layers in the Correct Order

6. Set the Colors of Your Custom Map Features in Adobe Illustrator

All right, we’re almost there. All that’s left is to set the colors of our map features. And thankfully, that’s an easy, straightforward task. On the map, hold down the Shift key and click on all of the features you want to color to select them. To set the color, go to the properties tab and set the fill and stroke colors. You can also add opacity to each feature if you wish. On the Utah National Parks map, we left the opacity at 100% for all features.

Utah National Parks map after coloring the parks white and removing the fill from the Utah boundary

Congratulations, you’re all done! You should have a final map that looks similar to the one below.

Conclusion

Creating a custom map in Adobe Illustrator is a fantastic way to increase brand awareness. And now, you’re completely ready to take the next big step into the world of map animation. You’ll learn all about that in the next installment of this series.

Additionally, custom maps are much easier to read and will put you leaps and bounds ahead of your competitors who are still using Google Maps. They’ll also make you look way more professional. Are you ready to get started with your own custom, branded maps? Get in touch with us today and get started with a free info session.

Top Photos: Hoodoos in the Late Afternoon Sun
Bryce Canyon National Park, Utah – May, 2017

The post How to Create a Custom Map in Adobe Illustrator appeared first on Matthew Gove Blog.

]]>
How to Import Shapefiles into Adobe Illustrator https://blog.matthewgove.com/2022/06/03/how-to-import-shapefiles-into-adobe-illustrator/ Fri, 03 Jun 2022 15:00:00 +0000 https://blog.matthewgove.com/?p=4744 GIS software is an incredibly powerful tool for displaying data on a map. However, they have their limits. And content creators often push well beyond those limits. Thankfully, Adobe Illustrator can help fill that void for creators that GIS programs, which are geared towards a much more technical audience, leave […]

The post How to Import Shapefiles into Adobe Illustrator appeared first on Matthew Gove Blog.

]]>
GIS software is an incredibly powerful tool for displaying data on a map. However, they have their limits. And content creators often push well beyond those limits. Thankfully, Adobe Illustrator can help fill that void for creators that GIS programs, which are geared towards a much more technical audience, leave behind. Today, you’re going to learn how to import GIS shapefiles into Adobe Illustrator. Not only will this enhance your professional brand, but also put you leaps and bounds ahead of the crowds that are still using Google Maps.

Which begs the question…why are so many people still using Google Maps screenshots in their videos, presentations, and other content? Yes, Google Maps is an incredible tool, but they were not designed to be used in videos and presentations. Worst of all, they tend to flash on the screen for such a short time that it’s next to impossible to tell where you are, where you’re going, or what you’re doing. In which of the following maps can you locate Utah’s “Big 5” National Parks faster?

Using Branded, Custom Maps Really Makes You Stand Out From the Crowds Still Using Google Maps

Creating custom maps in Adobe Illustrator can fix all of that. Put your own branding and style on the map. Remove everything that’s not relevant to the story you’re trying to tell. Give it a breathtaking design. Make it uniquely you. It’s such an easy way to look very professional and really stand apart from everyone still using Google Maps.

Finally, and best of all, you don’t have to spend a fortune to achieve incredible results with your maps. In this tutorial, the only thing you’ll need to pay for is Adobe Illustrator. Everything else is available free of charge. Let’s go.

What is a Shapefile?

A shapefile is simply a geospatial vector data format. Vector data formats in GIS and mapping applications are incredibly fast and efficient because of their small file size. You can put an enormous amount of data into a pretty small file, which also makes vector data formats ideal for web-based applications.

ESRI originally created the shapefile for its ArcView GIS software back in the early 1990’s. Today, shapefiles are widely used and nearly universally supported throughout the GIS world. However, I do want to point out that despite their widespread use, they are still a proprietary format. As a result, if you prefer open source file formats, I recommend using either GeoJSON or CSV to store your data. Both can be used as vector formats and you can import them into Adobe Illustrator using the same method we’ll use for shapefiles below.

Shapefiles exist for just about every type of feature out there. You can store data as points, lines, or polygons. Indeed, I’ve used them for everything, including severe weather warnings, road trip routes, National Park boundaries, and much more. Because of their widespread availability, both ESRI and government entities (federal, state/province, and local) maintain extensive databases of shapefiles. If you can’t find what you’re looking for there, you should be able to find it with a quick Google search. While this tutorial only uses the geometry of the shapefiles, you can easily add your own data either directly into the shapefile or through region mapping.

Shapefiles of the State of Utah and its “Big 5” National Parks Open in QGIS

Why Import Shapefiles into Adobe Illustrator?

If you’re just looking to plot data on a map, then by all means, a GIS program is the best way to go. However, GIS programs definitely have their limits. That’s where Adobe Illustrator comes in. When you import your shapefiles into Adobe Illustrator, you get much finer control over the final map design and look. The end result is a much more polished and professional-looking map, especially if you’re putting them into videos or presentations.

Furthermore, Adobe Illustrator provides the bridge to animating your maps. If you’re a content creator or giving a presentation, fully animated maps will put you in a class above your competition who are still using screenshots of Google Maps in their videos and presentations. Don’t believe me? Have a look at the maps below. Which one is easier to identify the “Big 5” National Parks in southern Utah?

While GIS software does support the bare basics for animation, you can make far more powerful animations even just using Illustrator itself. However, to unlock its full potential, you’ll need to use something like Adobe After Effects.

Click Play to See an Example of a Custom Map I made in Adobe Illustrator and Animated in After Effects

Unfortunately, animation is a topic for another day. We’ll cover that in a future tutorial. Let’s get back to learning how to import shapefiles into Adobe Illustrator.

1. Download and Install QGIS, a Free GIS Program

As a content creator myself, I know how critical it is to keep the cost of doing business to a minimum. And as a GIS specialist, I also know how expensive some proprietary GIS software can be. As a result, I’ve designed this tutorial so that the only piece of software you need to pay for is Adobe Illustrator.

If you’ve used ESRI’s ArcGIS before, you may be aware that Arc has an “Export to Illustrator” option built into it. That will export your shapefiles directly into a .ai Adobe Illustrator file. However, the desktop version of Arc also costs a bare minimum of $700 per year to use. Instead, we’ll use QGIS for this tutorial. QGIS is open source and, best of all, completely free. And unlike Arc, it runs on MacOS, Windows, and Linux. You can download QGIS here.

2. Prepare Your Shapefiles in QGIS

Before we can import our shapefiles into Adobe Illustrator, we first need to prepare them in QGIS. Using QGIS will ensure that each feature appears on your map in its proper location. You can try to eyeball the correct location once it’s all imported into Illustrator, but trust me, that never ends well.

Create a New Project in QGIS

First, you’ll need to create a new project in QGIS into which you’ll load your shapefiles. You’ll also need to change the default map projection, which will prevent your shapefiles from becoming distorted.

First, open QGIS and select Project > New Project. This will open a blank project. Then, in the bottom right, click on the text that says “EPSG:4326”. QGIS will open a window so you can select a new projection.

In the search bar, search for “Pseudo-Mercator”. You’ll likely see multiple results returned. Select the result labeled “EPSG:3857”.

Click OK to confirm your changes. The text in the bottom right should change from “EPSG:4326” to “EPSG:3857”.

Finally, if you want to include a basemap to confirm your features are both properly projected and in the correct location, double click on the OpenStreetMap option in the browser on the left-hand side of your QGIS dashboard. Please note that you should only use the basemap should a reference and never import it into Adobe Illustrator with the rest of your shapefiles.

Load Your Shapefiles into QGIS

When you prep your shapefiles in QGIS for import into Adobe Illustrator, you can include as many or as few as you want. When you export them to Adobe Illustrator, they’ll all get exported as a single-layer entity, so you don’t need to worry about keeping track of a ton of layers.

Adding shapefiles to your QGIS project is easy.

  1. Select Layer > Add Layer > Add Vector Layer from the top menu. A window will open.
  2. Under the “Source” section, you’ll see an input labeled “Vector Dataset(s)”. Click on the three dots to the right of the text input.
  3. Navigate to the folder with your shapefiles and select all the shapefiles you wish to load into QGIS. You only need to select files with the .shp extension.
  4. Click the “Add” button at the bottom of the window to add them to your QGIS project.
  5. Repeat steps 2-5 until all of your shapefiles are loaded into QGIS.
  6. Close the window.

Once everything is loaded into QGIS, make sure that all of the features in the shapefiles that you want to import into Adobe Illustrator are visible. You may need to re-arrange the layers in the Layers panel on the left hand side if you can’t see something.

Finally, hide any features or sublayers in the shapefiles that you do not want to import into Adobe Illustrator. Simply uncheck the feature in the Layers panel to hide it. If you need finer control for removing an individual item, you can easily do that once we import it into Illustrator.

Don’t Worry About Appearance in QGIS

Don’t worry about what the map looks like in QGIS. There’s no need to adjust colors, line thicknesses, or anything else. We’ll do that in Illustrator. Adobe Illustrator gives you much better and finer control over the look of the map than QGIS does. The one exception would be if two features are blocking each other and you need to remove the fill of one so you can see the other.

Finally, if you’ve used a basemap, uncheck it from the layers panel on the left to hide it. The basemap will create all kinds of headaches if you import it into Illustrator. Alternatively, if you’re having issues with white features on a white background in QGIS, just change the background color. You can easily delete that solid background once you get it into Illustrator.

To change the background color, follow these steps.

  1. In the top menu, select Project > Properties. A window will open.
  2. Click on the “General” tab in the upper-left.
  3. In the fourth row down from the top, click on the white box to the right of “Background color” and select the background color you wish.

3. Create a Layout in QGIS to Easily Export Your Shapefiles into Adobe Illustrator

First, zoom and pan the map in your QGIS project to the exact level and position you want to display it in Illustrator. It doesn’t need to be exact, but you should include a little more than you intend to use. It’s easy to clip off the extra after importing the map into Illustrator.

Once your map is zoomed and positioned correctly, it’s time to create a layout so you can export it out of QGIS. In the top menu, select Project > New Print Layout. Follow the prompts to create your new layout. For best results, make sure the layout size is set to either US Letter or A4. Then click the “Add Map” button on the left-hand side.

Finally, click and drag your map so it fills the blank layout. You should see your map appear. If you didn’t get the entire page filled, simply click and drag each corner of the map out to the corners of the blank layout.

Congratulations, you’re ready to export your map out of QGIS. Don’t close the layout window just yet, because you’ll still need it in the next step.

4. Export Your QGIS Layout into SVG Format

Scalable Vector Graphics, or SVG, is an open-source XML-based framework for defining two-dimensional scalable vector images. It’s the most common type of vector image used in web-based applications today. The main advantage of vector images is that they can be scaled infinitely up or down without losing quality or becoming pixelated. As a result, you can cram a huge amount of data into a very small file. And best of all, Illustrator can automatically convert your .svg image into its default .ai format on import.

To export your shapefiles into .svg format, go back to your layout window. In the top window of the layout window (not the main QGIS dashboard), select File > Export Image as SVG. Follow the prompts to save the .svg file to your local hard drive.

SVG File Exported from QGIS Opened in a Web Browser

One thing to be aware of is that QGIS may give you a warning about some SVG’s not being exported correctly. I have not had any issues with SVG exports, but if your SVG’s do not export correctly, simply export your shapefiles as a .pdf file instead. In the layout window, select File > Export Image as PDF. PDF files are also a vector format, and you follow the exact same steps to import everything into Illustrator, regardless of whether your file is an SVG or PDF.

If you encounter this warning, continue exporting your SVG. It will more likely than not export just fine.

5. Place Your Exported SVG File into Illustrator

All right, we’re almost there. All that’s left to do is to import our shapefiles (in SVG/PDF format) into Adobe Illustrator. Once that’s done, let your creative side take over and have some fun.

First, open Adobe Illustrator and create a new file. You can use any size artboard you want. However, because I create these maps for use in my travel videos, I’ll use a 4K (3840×2160) artboard.

Second, create a new layer that will hold only your SVG file. Putting the SVG file into its own layer allows us to filter, parse, and extract specific elements of the SVG file into our Illustrator project. Then, once we’ve extracted everything, all we have to do is delete or hide the SVG layer to remove all of the extras.

Linking vs. Embedding Images in Adobe Illustrator

When you import any kind of image into Adobe Illustrator, you can choose whether to embed the file in Illustrator or just link to it. Linking the image file means that Illustrator will reference it from wherever it is on your computer. If you move or delete the image, it will disappear from your Illustrator project. Embedding, on the other hand, copies the image into Illustrator and saves it as part of the .ai file. That way, if you move or delete the original image file, it will still be in your Illustrator project.

Because your exported shapefile vectors are so small, I highly recommend you embed the SVG into Illustrator. Embedding the SVG into Illustrator is easy and straightforward.

  1. In the top menu, select File > Place.
  2. Navigate to the SVG File you exported from QGIS. Click “Add”.
  3. Click anywhere in your Illustrator window to place the SVG.
Your map will likely not look terribly glorious when you first import it into Adobe Illustrator

You should now see the SVG file that you exported from QGIS. However, it’s probably not in the right place in the Illustrator window, nor is it scaled correctly.

A Note on Moving and Scaling Your SVG File in Adobe Illustrator

Adobe Illustrator automatically separates the features in your SVG file to mirror the original shapefile. That’s a good thing, as it makes incredibly easy to separate out each element in Illustrator. However, if you’re not careful, you can easily move or scale features of your map out of place. Thankfully, it doesn’t take much to prevent things from moving out of place.

The easiest way to move or scale the SVG as a whole is to lock all of the other layers first. Because the SVG is in its own layer, then all we have to do is just hit Control + A on Windows or Command + A on a Mac to select all. With the other layers being locked, you’ve selected your entire SVG file without bothering anything else in the Illustrator file.

Second, make sure you hold down the Shift key when scaling the SVG. Doing so maintains the aspect ratio of the SVG. Without it, your map will become distorted and misshapen.

Positioning Your Map in Adobe Illustrator

it’s best to center your map in your Illustrator project, filling as much of the artboard as possible. However, make sure you leave room, particularly at the top, for any titles, headers, labels, and legends you would like to include.

At this point, it’s still perfectly fine if parts of the map extend beyond the boundaries of the artboard. We’ll delete those parts in the next section. And remember, you’re working with vectors, so you can infinitely scale them up or down without losing quality or pixelating.

6. Organize the components of the SVG into Layers in Adobe Illustrator

Depending on what you’re using the Illustrator map for, this can be one layer or many. It’s entirely up to you. However, do note that if you’re animating the map, every individual item or group of items that you’ll be animating as a single unit needs to be in their own layer. In other words, you can’t animate pieces of a layer. You can only animate the whole layer.

Additionally, if you have roads or routes on your map, make sure that you join the pieces of each route together so the route can be a single entity on the map. Having a route in several pieces can be an absolute nightmare if you’re trying to animate it. But even if it’s just going to be static, it’s still much easier to manage a single route than several pieces of it. To join paths in Illustrator, select each element of the paths you want to join and go to Object > Path > Join.

How to Extract SVG Components into Adobe Illustrator Layers

  1. Click the New Layer button on the bottom right of the Illustrator window to create a new layer.
  2. Go through the components of the SVG layer and find the ones you want to extract. This may take some trial and error by showing and hiding each piece.
  3. In the Layers panel in Illustrator, click and drag that component from the SVG layer to the new layer.
  4. Adjust the line width, colors, fills, strokes, opacities, etc. to set the final look or design of the feature you just moved.
  5. Add any features to the layer that were not in the SVG file. These are most often the feature labels you can add with Illustrator’s text tool.
  6. Repeat steps 1 through 5 for each feature layer you wish to create.
The Utah “Big 5” National Parks in Illustrator After Being Extracted From the SVG File

When you finish extracting the SVG components you’re using in your Illustrator map, there will likely still be features left over in the SVG layer that you’re not using. Putting the SVG file in its own layer makes it very easy to clean up the leftovers. If you know you’re not going to be using anything else in the SVG layer, you can go ahead and delete the layer. On the other hand, if you know you’re going to be using the leftovers or are not sure, simply hide the SVG layer so you can access it later.

Conclusion

Being able to export ESRI shapefiles into Adobe Illustrator opens up a whole new set of opportunities for content creators, artists, and other creatives to use maps. Creating professional branded, elegant, and easy-to-read maps in Adobe Illustrator will put you leaps and bounds ahead of the masses that are still using screenshots of Google Maps in their videos and presentations.

In the next tutorial, learn how to transform the extracted layers above into this.

In future tutorials, we’ll go over how to put the full Illustrator files together like you see in my travel videos. Then, learn how to animate your maps using both Adobe Illustrator and After Effects. In the meantime, we’d love to help you get started with your creative maps and animations. Please get in touch with us today to discuss your project and how we can bring your mapping visions to life.

Top Image: Warm Later Afternoon Light Provides a Dramatic Contrast Against Grey Winter Skies
Canyonlands National Park, Utah – December, 2021

The post How to Import Shapefiles into Adobe Illustrator appeared first on Matthew Gove Blog.

]]>
How to Bulk Edit Your Photos’ EXIF Data with 10 Lines of Python https://blog.matthewgove.com/2022/05/13/how-to-bulk-edit-your-photos-exif-data-with-10-lines-of-python/ Fri, 13 May 2022 15:00:00 +0000 https://blog.matthewgove.com/?p=4637 Keeping up-to-date EXIF data is critically important for managing large libraries of photos. In addition to keeping your library organized, EXIF data also lets you sort, filter, and search your photo library on numerous criteria, making it easy to find the images you want, and fast. Unfortunately, many photographers, including […]

The post How to Bulk Edit Your Photos’ EXIF Data with 10 Lines of Python appeared first on Matthew Gove Blog.

]]>
Keeping up-to-date EXIF data is critically important for managing large libraries of photos. In addition to keeping your library organized, EXIF data also lets you sort, filter, and search your photo library on numerous criteria, making it easy to find the images you want, and fast. Unfortunately, many photographers, including myself, tend to let things slip when it comes to keeping metadata up to date. As a result, when it comes time to edit your EXIF data, you need to do it in bulk, which can be a tedious and time-consuming task.

EXIF stands for Exchangeable Image Format. It’s a standard that defines the data or information related to any media you capture with a digital camera. It can include data such as:

EXIF Data Seen in Adobe Lightroom
  • Image Size
  • File Name and Location on Your Computer
  • Camera and Lens Make/Model
  • Exposure Settings (Aperture, Shutter, ISO, etc)
  • Date and Time the Photo was Taken
  • Location and Elevation Where the Photo was Taken
  • Photographer’s Name and Contact Info
  • Copyright Info
  • Software Used to Post-Process the Image
  • Much More

Why Do You Need to Edit EXIF Data?

Regardless of whether you need to add or remove EXIF data, there are plenty of reasons to edit it. In my nearly two decades doing photography, here are some of the more common reasons I’ve had to edit EXIF data.

  • Strip out sensitive information when you post photos publicly on the web
  • Add location data or geotag images for cameras that don’t have GPS
  • Add or update titles, descriptions, and captions
  • Rate, label, and tag images
  • Add or update your contact info and/or copyright information
Maintaining Fully-Populated EXIF Data Makes Browsing and Searching Your Photo Library a Breeze

If you’re planning to sell your photography in any way, shape, or form, you better have fully populated EXIF data. For example, let’s consider stock photography websites. They use the EXIF data embedded in your images to return the most relevant images in search results. Without fully-populated EXIF data, your images won’t be returned in their searches, and you won’t make any sales as a result.

Available Tools to Bulk Edit EXIF Data

Thankfully, there are numerous tools available so you can edit your photos’ EXIF data. They all support bulk editing, so it doesn’t matter whether you’re updating one photo or a million.

  • Photo editors and organizers such as Adobe Lightroom
  • EXIF Editors are available for all operating systems, including iOS and Android. Many are free.
  • Python

Do be aware that while many EXIF editors advertise themselves as free, they often come with heavy restrictions if you don’t want to pay for the full software. Because of these restrictions, Python is one of the few tools that can edit EXIF data both for free and without restrictions. In this tutorial, we’re going to use Python to add EXIF data to a series of images.

Python Image Libraries

In previous tutorials, we’ve used Python’s Pillow Library to do everything from editing and post-processing to removing noise from and adding location data to photos. And we’ll show in this tutorial that you can use Pillow to add, edit, and remove EXIF data. However, there’s a better Python tool to manage and edit your EXIF data: the exif library.

So what makes the exif library better than Pillow? For that, we have to look at how the computer stores and reads EXIF data. In the computer, EXIF parameters are stored as numeric codes instead of English words. For example, instead of “Camera Make”, the computer just sees 271. Likewise, the computer sees 36867 instead of “Date/Time Image Taken”.

To edit the EXIF data using Pillow, you need to know the numeric key for each field you want to edit. Considering that there are thousands of these numeric keys in use, you’ll spend an incredible amount of time just searching for they numeric keys you want. On the other hand, the exif library uses human-readable keys to edit the EXIF data. We’ll go over how to use both libraries, so you can decide which one you prefer.

Install the Pillow and Exif Libraries (If You Haven’t Already)

Before diving into EXIF data, you’ll need to install the Python Pillow and Exif libraries if you haven’t already. With pip, it’s a couple quick commands in a Terminal or Command Prompt.

pip3 install pillow
pip3 install exif

Import the Image Property from both the Pillow and Exif Libraries into Your Python Script

In order to run code from the Pillow and Exif libraries, you’ll need to import the Image property from each library into your Python script. To avoid name conflicts, we’ll call them ExifImage and PillowImage. From the Pillow library, we’ll also import the ExifTags property, which converts the numeric EXIF tags into human-readable tags.

from exif import Image as ExifImage
from PIL import Image as PillowImage
from PIL import ExifTags

Images for this Demo

I’ve included three images with this tutorial, but you can add as many of your own as you please. One set has the metadata intact, which we’ll use for reading the metadata. I stripped the EXIF data out of the other set, so we can add it with Python. I also took the images with three different cameras.

Image DescriptionCameraGeotagged
Chicago Cubs vs Boston Red Sox Spring Training game in Mesa, ArizonaSamsung GalaxyYes
Stonehenge Memorial in Washington StateNikon D3000No
Beach Scene on Cape Cod, MassachusettsCanon EOS R5No

Back Up Your Images Before You Begin

Before you do anything with the Python code, make a copy of the folder containing your original images. You never know when something will go wrong. With a backup, you can always restore your images to their original state.

Reading EXIF Data with Python

First, we’ll loop through the images and extract the camera make and model, the date and time the image was taken, as well as the location data.

ParameterPillow PropertyExif Property
Camera Make271make
Camera Model272model
Timestamp36867datetime_original
GPS Info34853gps_latitude, gps_longitude

The steps to read the EXIF data from each image and output it to the terminal window are as follows.

  1. Open the image
  2. Extract the value of each metadata tag displayed in the table above
  3. Print the human-readable tag and the value in the terminal window.

Define the Universal Parameters You’ll Use to Extract EXIF Data in the Python Script

In our Python script, the first thing we need to do is define the universal parameters we’ll use throughout the script. First, we’ll create a list of the image filenames.

images = ["baseball.jpg", "cape-cod.jpg", "stonehenge.jpg"]

Next, define the EXIF Tags for the Pillow library that will extract the data we want. Remember, that Pillow uses the EXIF numeric tags.

PILLOW_TAGS = [
    271,    # Camera Make
    272,    # Camera Model
    36867,  # Date/Time Photo Taken
    34853,  # GPS Info
]

Finally, create a variable to store the EXIF tags for the Exif library. The Exif library uses human-readable tags, so please consult their documentation for the full list of tags.

EXIF_TAGS = [
    "make",
    "model",
    "datetime_original",
    "gps_latitude",
    "gps_latitude_ref",
    "gps_longitude",
    "gps_longitude_ref",
    "gps_altitude",
]

Read EXIF Data with the Pillow Library

To extract the EXIF data from all of the images at once, we’ll loop through the images variable we defined above. We’ll print the image filename and then set the image path inside the with-metadata folder.

for img in images:
    print(img)
    image_path = "with-metadata/{}".format(img)

Next, open the image with Pillow and extract the EXIF data using the getexif() method.

pillow_img = PillowImage.open(image_path)
img_exif = pillow_img.getexif()

Now, we’ll loop through the tags. Pillow has a property called ExifTags that we’ll use to get the human-readable definition of each numeric tag. Do note that you’ll need to wrap it in a try/except block to skip properties that are not set. Without it, you’ll get an error and the script will crash if a property is not set. For example, the Cape Cod and Stonehenge images do not have GPS/location data. Finally, print the human-readable tag and the value to the Terminal window.

for tag in PILLOW_TAGS:
    try:
        english_tag = ExifTags.TAGS[tag]
        value = img_exif[tag]
    except:
        continue
    print("{}: {}".format(english_tag, value))

Final Pillow Code

Put it all together into nice, compact block of code.

for img in images:
    print(img)
    image_path = "with-metadata/{}".format(img)
    pillow_img = PillowImage.open(image_path)
    img_exif = pillow_img.getexif()
    
    for tag in PILLOW_TAGS:
        try:
            english_tag = ExifTags.TAGS[tag]
            value = img_exif[tag]
        except:
            continue
        print("{}: {}".format(english_tag, value))

When you run the script, it will output the info about each photo.

baseball.jpg
Make: samsung
Model: SM-G965F
DateTimeOriginal: 2019:03:25 18:06:05
GPSInfo: æ0: b'Øx02Øx02Øx00Øx00', 1: 'N', 2: (33.0, 25.0, 50.0), 3: 'W', 4: (111.0, 52.0, 53.0), 5: b'Øx00', 6: 347.0, 7: (1.0, 6.0, 0.0), 27: b'ASCIIØx00Øx00Øx00GPS', 29: '2019:03:26'å

cape-cod.jpg
Make: Canon
Model: Canon EOS R5
DateTimeOriginal: 2022:03:22 20:58:52

stonehenge.jpg
Make: NIKON CORPORATION
Model: NIKON D3000
DateTimeOriginal: 2022:02:16 21:36:08

A Quick Word on Interpreting the GPS Output

When you look at the GPS output, you’re probably wondering what the hell you’re looking at. To decipher it, let’s break it down and look at the important components. FYI, Pillow returns latitude and longitude coordinates as tuples of (degrees, minutes, seconds).

1: 'N', 
2: (33.0, 25.0, 50.0), 
3: 'W', 
4: (111.0, 52.0, 53.0),
6: 347.0,

Here’s what it all means.

  1. 'N' indicates that the latitude coordinate is in the northern hemisphere. It returns 'S' for southern hemisphere latitudes.
  2. (33.0, 25.0, 50.0) contains the degrees, minutes, and seconds of the latitude coordinates. In this case, it’s 33°25’50″N.
  3. 'W' indicates that the longitude coordinate is in the western hemisphere. It returns 'E' for eastern hemisphere longitudes.
  4. The (111.0, 52.0, 53.0) tuple contains the degrees, minutes, and seconds of the longitude coordinates. Here, it’s 111°52’53″W.
  5. 347.0 is the altitude at which the photo was taken, in meters.

Remember, it’s the baseball picture that’s geotagged. If we plot those coordinates on a map, it should return the Chicago Cubs’ Spring Training ballpark in Mesa, Arizona. Indeed, it even correctly shows us sitting down the first base line.

Chicago Cubs vs. Boston Red Sox Spring Training Game in March, 2019

Read EXIF Data with the Exif Library

Extracting EXIF data from your photos using the Exif library is very similar to the Pillow library. Again, we’ll start by printing the image filename and set the image path inside the with-metadata folder.

for img in images:
    print(img)
    image_path = "with-metadata/{}".format(img)

Next, we’ll read the image into the Exif library. However, unlike Pillow, the Exif library automatically extracts all the EXIF data when you instantiate the Image object. As a result, we do not need to call any additional methods or functions.

with open(image_path, "rb") as input_file:
    img = ExifImage(input_file)

Because the Exif library automatically extracts the EXIF data, all you need to do is just loop through the tags and extract each one with the get() method. And unlike the Pillow library, the Exif library also automatically handles instances where data points are missing. It won’t throw an error, so you don’t need to wrap it in a try/except block.

for tag in EXIF_TAGS:
    value = img.get(tag)
    print(“{}: {}”.format(tag, value))

Final Exif Library Code

When you put everything together, it’s even cleaner than using the Pillow library.

for img in images:
    print(img)
    image_path = “with-metadata/{}”.format(img)
    with open(image_pdaath, ”rb”) as input_file:
        img = ExifImage(img_file)

    for tag in EXIF_TAGS:
        value = img.get(tag)
        print(“{}: {}”.format(tag, value))

When you run the script, the output from the Exif library should be identical to the output from the Pillow library, with one exception. The Exif Library breaks down the GPS data into its components. You’ll still get the same tuples you do with the Pillow library, but it labels what each component of the GPS data is using English words instead of numeric codes.

baseball.jpg
make: samsung
model: SM-G965F
datetime_original: 2019:03:25 18:06:05
gps_latitude: (33.0, 25.0, 50.0)
gps_latitude_ref: N
gps_longitude: (111.0, 52.0, 53.0)
gps_longitude_ref: W
gps_altitude: 347.0

cape-cod.jpg
make: Canon
model: Canon EOS R5
datetime_original: 2022:03:22 20:58:52
gps_latitude: None
gps_latitude_ref: None
gps_longitude: None
gps_longitude_ref: None
gps_altitude: None

stonehenge.jpg
make: NIKON CORPORATION
model: NIKON D3000
datetime_original: 2022:02:16 21:36:08
gps_latitude: None
gps_latitude_ref: None
gps_longitude: None
gps_longitude_ref: None
gps_altitude: None

Writing, Editing, and Updating EXIF Data Using Python

To demonstrate how to write and edit EXIF data, we’re going to add a simple copyright message to the all three images. That message will simply say ”Copyright 2022. All Rights Reserved.” We’ll also add your name to the EXIF data as the artist/photographer.

Universal Tags We’ll Use Throughout the Python Script

Just like we did when we read the EXIF data from the image, we’ll define the artist and copyright tags we’ll use to edit the EXIF data in each library. We’ll also store the values we’ll set the tags to in the VALUES variable.

PILLOW_TAGS = [
    315,     # Artist Name
    33432,   # Copyright Message
[

EXIF_TAGS = [
    “artist”,
    ”copyright”,
]

VALUES = [
    “Matthew Gove”,    # Artist Name
    ”Copyright 2022 Matthew Gove. All Rights Reserved.”  # Copyright Message
]

How to Edit EXIF Data with the Pillow Library

In order to edit the EXIF data, you need to open the image with the Pillow Library and load the EXIF data using the getexif() method. This code is identical to when we read the metadata. The only difference is that we’re loaded the image from the without-metadata folder.

for img in images:
    image_path = “without-metadata/{}”.format(img)
    pillow_image = PillowImage.open(image_path)
    img_exif = pillow_img.getexif()

Now, all we have to do is loop through the tags we want to set (which are in the PILLOW_TAGS variable) and set them to the corresponding values in VALUES.

for tag, value in zip(PILLOW_TAGS, VALUES):
    img_exif[tag] = value

Finally, just save the changes to your image. For the purposes of this tutorial, we are saving the final images separate from the originals. When you update your EXIF data, feel free to overwrite the original image. You can always restore from the backup we made if needed.

output_file = img
pillow_img.save(output_file, exif=img_exif)

That’s all there is to it. When you put it all together, you have a nice, efficient, and compact block of code.

for img in images:
    image_path = “without-metadata/{}”.format(img)
    pillow_image = PillowImage.open(image_path)
    img_exif = pillow_img.getexif()

    for tag, value in zip(PILLOW_TAGS, VALUES):
        img_exif[tag] = value

    output_file = img
    pillow_img.save(output_file, exif=img_exif)

How to Edit EXIF Data with the Exif Library

Editing EXIF data with the Exif library is even easier than it is using Pillow. We’ll start by loading the image without the metadata into the Exif library. You can cut and paste this code from the script that reads the EXIF data. Just don’t forget to change the with-metadata folder to without-metadata.

for img in images:
    image_path = “without-metadata/{}”.format(img)
    with open(image_path, ”rb”) as input_file:
        exif_img = ExifImage(input_file)

Here’s where it gets really easy to edit the EXIF data and set new values. If you have a lot of EXIF data to edit, by all means put everything into a loop. However, for simplicity, you also do this.

exif_img.artist = “Matthew Gove
exif_img.copyright = “Copyright 2022 Matthew Gove. All Rights Reserved.”

Then save the file. Like we did with the Pillow library, we’ll save everything to a new file for purposes of the tutorial. However, feel free to overwrite the images when you use it in the real world.

output_filepath = img
with open(output_filepath, ”wb”) as ofile:
    ofile.write(exif_img.get_file())

Put it all together and you can update and edit your EXIF data with just 10 lines of Python code.

for img in images:
    image_path = "without-metadata/{}".format(img)
    with open(image_path, "rb") as input_file:
        exif_img = ExifImage(input_file)
    
    exif_img.artist = "Matthew Gove"
    exif_img.copyright = "Copyright 2022 Matthew Gove. All Rights Reserved."

    with open(img, "wb") as ofile:
        ofile.write(exif_img.get_file())

Confirming Your EXIF Edits Worked

The final step in editing your EXIF data is to confirm that the Python code actually worked. In the script, I copied logic from when we read the EXIF data to confirm that our edits were added and saved correctly. Indeed, when you run the script, you’ll see the following confirmation in the Terminal window. Alternatively, you can open the photo in any photo editor, such as Adobe Lightroom, to confirm that the new EXIF data has been added to it.

PILLOW
=======
baseball.jpg 
Artist: Matthew Gove
Copyright: Copyright 2022 Matthew Gove. All Rights Reserved.

cape-cod.jpg
Artist: Matthew Gove
Copyright: Copyright 2022 Matthew Gove. All Rights Reserved.

stonehenge.jpg
Artist: Matthew Gove
Copyright: Copyright 2022 Matthew Gove. All Rights Reserved.

################################

EXIF
======
baseball.jpg
artist: Matthew Gove
copyright: Copyright 2022 Matthew Gove. All Rights Reserved.

cape-cod.jpg
artist: Matthew Gove
copyright: Copyright 2022 Matthew Gove. All Rights Reserved.

stonehenge.jpg
artist: Matthew Gove
copyright: Copyright 2022 Matthew Gove. All Rights Reserved.

Download the Code in This Tutorial

You can download the code we wrote in this tutorial from our Bitbucket repository. Please feel free to play around with it and update it to suit your needs. If you have any questions, leave them in the comments below.

Conclusion

Python is an incredibly powerful tool to update and edit your EXIF data. And best of all, it’s one of the few EXIF editing tools that is completely free, without any restrictions on what you can do with it. It’s fast, easy-to-use, and infintely scalable. EXIF metadata is not the sexiest aspect of photography by any means. But it is one of the most critical. When you don’t manage it correctly, you are literally costing yourself both time and money.

If you want help getting started with your EXIF data, please get in touch with us today. As experts in both photography and data science, there are not many people who know the ins and outs of EXIF data better than we do. Alternatively, if you would just like to see more tutorials, I invite you to please join our email list and subscribe to our YouTube channel. See you in the next tutorial.

The post How to Bulk Edit Your Photos’ EXIF Data with 10 Lines of Python appeared first on Matthew Gove Blog.

]]>
How to Geotag Your Photos in Adobe Lightroom Without a Built-in GPS https://blog.matthewgove.com/2022/04/22/how-to-geotag-your-photos-in-adobe-lightroom-without-a-built-in-gps/ https://blog.matthewgove.com/2022/04/22/how-to-geotag-your-photos-in-adobe-lightroom-without-a-built-in-gps/#comments Fri, 22 Apr 2022 15:00:00 +0000 https://blog.matthewgove.com/?p=4270 As both a GIS professional and digital nomad, being able to geotag photos is critical to staying organized. With travel photography, you need to be able to search by both date and location, at the very least. But believe it or not, I’ve never owned a camera with a built-in […]

The post How to Geotag Your Photos in Adobe Lightroom Without a Built-in GPS appeared first on Matthew Gove Blog.

]]>
As both a GIS professional and digital nomad, being able to geotag photos is critical to staying organized. With travel photography, you need to be able to search by both date and location, at the very least. But believe it or not, I’ve never owned a camera with a built-in GPS. Today, I want to teach you how to geotag your photos in Adobe Lightroom without having a built-in GPS. And best of all, this method is infinitely scalable. It requires just one GPS and the same minimal effort regardless if you’re shooting with one camera or a thousand.

An Introduction to the Lightroom Map Area

Adobe Lightroom comes with a really nice map interface to browse, explore, and view your photos. Unfortunately, if your photos aren’t geotagged, the feature is worthless.

Map in Adobe Lightroom Showing a Subset of Geotagged Photos I Took on a Recent Trip to Grand Teton National Park in Wyoming

Lightroom’s map feature lets you browse, explore, and view your photos and videos on an interactive map. You can also easily edit and geotag your photos from the map, as well as create collections, tag keywords, and much more.

Are You One of the Many Travel Photographers Struggling to Geotag Your Photos in Lightroom Without a Built-in GPS?

If your photos and videos are already geotagged when you import them into Lightroom, the map gets set up automatically. However, many cameras still don’t have built-in GPS. You can buy a GPS adaptor to mount to the top of your camera, but they come with plenty of drawbacks. First, with a GPS mounted to the top of your camera, you won’t be able to mount a flash or a mic there. And what if you have multiple cameras? At $200-300 a pop, the cost of outfitting each camera with a GPS unit can snowball out of control incredibly fast.

Alternatively, you can use a smartphone app that your camera manufacturer makes. When you snap a picture, the app uses the GPS in your phone to record the location and sends it to your camera over bluetooth. While I have not used these apps much, be aware that smartphones usually disable the GPS when it’s not actively in use to conserve battery. Unfortunately, if you phone’s GPS goes into standby or sleep mode during a photo shoot, it will often send the last location the GPS registered, which may not necessarily be your current location. As a result, many people have complained that these apps are not accurate or reliable for geotagging photos and videos.

So where do you go from here? This is where my method comes in. This method is by no means anything bleeding edge or earth-shattering. In fact, a quick Google search will reveal that it’s widely used throughout the photography and filmmaking industries. And best of all, it only requires one GPS regardless of how many cameras you have. However, there are still a few places it can trip you up. As a result, I want to use my background in GIS and data science to make sure that you fully understand both what the data is and what you’re doing with it. You unfortunately won’t find that in many other tutorials.

How to Use Handheld GPS (or Smartphone) to Geotag Your Photos and Videos in Adobe Lightroom

The strategy to geotag photos in Adobe Lightroom without a built-in GPS is staggeringly simple. While you’re out on your photo or video shoot, use a handheld GPS to record your movement. Then, in post-production match the timestamp on the GPS track to the timestamp on your camera to get the latitude and longitude coordinates for the geotag. Once you add the latitude and longitude to the metadata, Lightroom will automatically look up and add the city, state/province, and country that correspond to those coordinates.

I use a simple handheld GPS to log my adventures in GPX files

Software You’ll Need

The only software you need to geotag your photos without a built-in GPS is Adobe Lightroom itself. Additionally, depending on what GPS and computer models you’re using, you may need additional software to pull the track off the GPS. If you have a Garmin GPS, don’t worry. All of their software is available free of charge. For example, my handheld GPS uses Garmin’s Basecamp software to offload the track data. On the other hand, the GPS I use in the car mounts like an external hard drive, so I can copy the track to my local disk using the Finder or File Explorer.

The track files you pull off your GPS are stored in GPS Exchange, or GPX format. GPX is an open source, non-proprietary file that stores GPS data for software applications. Data is stored in XML format, which is light-weight and usable in both desktop and web-based applications. In addition to latitude/longitude coordinates and timestamps, GPX files can also store speed, elevation, waypoints, routes, points of interest, and much more.

You can view GPX files in numerous desktop and web-based applications, ranging from Google Maps to QGIS and ArcMap to even the Matt Gove Photo maps. However, for the purpose of geotagging photos, the easiest application to view your GPX files is actually Lightroom. You can preview your track right in the Lightroom map before you geotag your photos.

Previewing a GPX File from my adventure in Wyoming last February in Adobe Lightroom

Sync the Clocks on Your GPS and Camera Before You Head Out in the Field

Before you head out for your shoot, your single most important task is to sync the clocks between your handheld GPS and each camera you’ll be using. If the clocks are not synced, your photos and videos will not be geotagged in the correct location.

If your travels keep you confined to a single time zone, feel free to sync everything to your local time zone. However, if your travels take you across multiple time zones, you should sync all of your devices to UTC. Also called Zulu Time, UTC is the modern standard that the world uses to regulate time. It differs from Greenwich Mean Time (GMT), as GMT is based on the Earth’s rotation, while the more accurate UTC is based on the atomic measurements.

If your camera or GPS does not offer UTC as a time zone, set it to London (make sure daylight savings is off) or Iceland. In addition, Dakar, the capital of Senegal, is on UTC year-round.

One of my cameras set to UTC using London’s Time Zone with Daylight Savings Disabled
Time ZoneWinter OffsetSummer Offset
NewfoundlandUTC – 3:30UTC – 2:30
AtlanticUTC – 4UTC – 3
EasternUTC – 5UTC – 4
CentralUTC – 6UTC – 5
MountainUTC – 7UTC – 6
PacificUTC – 8UTC – 7
AlaskaUTC – 9UTC – 8
HawaiiUTC – 10UTC – 10
U.S. and Canada Time Zone Offsets from UTC, from East to West

Once you get out in the field where you’ll be shooting, simply turn on your handheld GPS and throw it in your bag, or put it somewhere that will be out of the way, but with you all day. Make sure the batteries are all charged at the beginning of the day. Finally, don’t forget to carry a spare set of batteries if you’re expecting a lengthy shoot.

Add Location Data in Post-Production in Adobe Lightroom

Now that your shoot is finished, it’s time to geotag your photos and videos in Lightroom. Before we get started, though, there’s another important note about time zones that if not done correctly, will result in your photos not being geotagged correctly.

A Word of Caution About Time Zones in GPX Data vs EXIF Camera Metadata

If you’ve synced your GPS and cameras to UTC, be aware of the difference in how GPX files handle time zones vs the camera’s EXIF metadata. GPX files have the time zone embedded in them. EXIF metadata records the time in the time zone that your camera is set to, but does not actually record the time zone itself in the metadata. In other words, the GPX file sees the time stamp as “2022-04-11 15:21 UTC”, while the EXIF metadata in the camera only sees “2022-04-11 15:21”.

Why is this important, you ask? Because when you offload the GPX file to your computer, your computer automatically converts its timestamp back to local time. For example, let’s say I’m on the east coast of the US, which is 4 hours behind UTC. The computer all of a sudden now sees the GPX timestamp as “2022-04-11 11:21 EDT”, while it still sees the EXIF metadata as “2022-04-11 15:21” (which it incorrectly assumes is also EDT because the EXIF data does not include the time zone). If you try to sync your photos to the GPX track, they’ll all be four hours off!

Thankfully, re-aligning the time zones is incredibly easy in Adobe Lightroom. When you load the GPX file into Lightroom, it will ask you if you want to correct the time zone. If you’ve synced your cameras to UTC, simply take the UTC offset of your local timezone and reverse the sign. For example, if you’re on the US east coast, which is UTC-4, set the time zone correction to +4 hours. This tells Lightroom to add 4 hours to the “2022-04-11 11:21 EDT” GPX timestamp, syncing it back up with the “2022-04-11 15:21” timestamp on the camera.

Menu Option to Adjust the Time Zone of a GPX File in Lightroom

Still confused? If you don’t want to deal with having to adjust timezones in Lightroom, there’s an easy alternative. Simply set your computer’s time zone to UTC before you import anything into Lightroom. Once you’re finished geotagging your photos, set the time zone on your computer back to local time.

Import the GPX File and the Photos and Videos From Your Shoot into Lightroom

To import the GPX File into Lightroom, first open the map viewer. At the bottom of the window, you’ll see a bar to select the map style, a zoom slider, a lock, and a track button, which is circled in green below.

Click the track button and select “Load Tracklog” at the very top of the menu. Navigate to the tracklogs you just pulled off your GPS. Click OK to load them into Lightroom.

Now, you’ll set the time zone offset as we discussed in the previous section. If you’re working in your local time zone (or have set your computer’s time zone to UTC to match the camera and GPS), you don’t need to add any offset to the track. Remember, if you synced the camera and GPS to UTC, simply take the UTC offset of your local time zone and flip the sign. In other words, set the offset to +4 hours for Eastern Time (UTC-4) or +7 hours for Pacific Time (UTC-7). Click OK to confirm the time zone offset.

You should see the trackline from your adventure appear on the map. Do note that if Lightroom detects that your tracklog time zone does not appear to match the time zone of your photos, it will highlight the trackline log time in red. In that case, click the track button at the bottom and select “Set Time Zone Offset” to set the correct time zone.

GPX Track After Being Imported into Lightroom

Once you’ve confirmed that the track loaded correctly, then import your photos and videos just like you always have.

Geotag Your Photos in Lightroom with the Click of a Button

Now that both the track and your media are all in place, it’s time to geotag them in Lightroom. In the filmstrip at the bottom of the window, select the photos and videos you want to geotag. Then, click on the track button once again, and select “Auto-Tag XX Selected Photos”, where XX is the number of photos you selected.

Geotagging Images from the Columbia River Gorge in Oregon and Washington

You should see a bunch of points appear on your trackline. Hover over them and you’ll see your photos. If they’re not quite in the right position, you can drag them around to put them in the right place.

Geotagged Images from My Adventure at the Columbia River Gorge

Don’t Have a Handheld GPS? Use a Smartphone Instead.

If you don’t have a handheld GPS, there are plenty of smartphone apps out there to generate a GPX file of your adventure. In the past I’ve always used the AllTrails app, which is available for free for both Apple and Android devices. AllTrails is designed for hiking and biking, but you can use it to track any activity. Here are directions to export your track from the AllTrails app. Make sure you export it as a GPX track, and not a GPX route.

Alternate Methods to Geotag Your Photos in Lightroom without a Built-in GPS

While geotagging photos and videos in Adobe Lightroom using a GPX track is by far the easiest and most accurate way to add location data to your images and videos, it’s not the only way.

First off, Lightroom offers several ways to add location data manually. You can directly edit the metadata of your images directly in Lightroom, or use the map interface to geotag your images. You can find plenty of tutorials for manual geotagging with a quick Google search. For more information, here is Adobe’s official documentation.

Unfortunately, there are quite a few drawbacks to geotagging your images manually. While it works fine for a few photos, it’s impossible to scale up to large photo albums, collections, and libraries, unless you have a serious amount of both time and will to put into it.

You can also geotag your photos using Python. We’ll cover this in a future tutorial, but you can use Python’s Pillow library to add location to your images’ metadata. You’ll need to loop through your image files, add the appropriate location metadata (lat/long coordinates or city/state/country), and then save the files. Be aware that this can get very complicated if you have a lot of photos taken in a lot of different locations. However, unlike manually adding location data, using Python is infinitely scalable, both up and down.

Conclusion

Geotagging photos is a critical part of both the workflow and staying organized as a landscape and travel photographer. With so many cameras still lacking built-in GPS functionalities, it becomes even more critical to know how to geotag photos in Adobe Lightroom without built-in GPS. Using GPX track files is by far the best alternative to built-in GPS that’s out there. Except for a few spots time zones can trip you up, the method is foolproof, accurate, reliable, and only requires one GPS, regardless of how many cameras you have. In my book, though, the benefits of having a geotagged library far outweigh the occasional hiccup from a mislabeled time zone.

Interested in more of these tutorials? I’n addition to the blog entries, I’ll be posting them to YouTube and sending them out via our email newsletter as well. Please subscribe to our email newsletter and our YouTube channel for the latest tutorials, and get exclusive deals to our online store that are not available anywhere else.

The post How to Geotag Your Photos in Adobe Lightroom Without a Built-in GPS appeared first on Matthew Gove Blog.

]]>
https://blog.matthewgove.com/2022/04/22/how-to-geotag-your-photos-in-adobe-lightroom-without-a-built-in-gps/feed/ 1
How to Remove Noise from Photos with 14 Lines of Python…and Blow Lightroom Out of the Water https://blog.matthewgove.com/2022/02/11/how-to-remove-noise-from-photos-with-14-lines-of-python-and-blow-lightroom-out-of-the-water/ Fri, 11 Feb 2022 16:00:00 +0000 https://blog.matthewgove.com/?p=3946 As a photographer, you will run into the frustration of noise in their low-light photos and having to remove it at some point. It’s a much of a guarantee as taxes and death. No matter what you do in post processing, it seems like every adjustment you make only makes […]

The post How to Remove Noise from Photos with 14 Lines of Python…and Blow Lightroom Out of the Water appeared first on Matthew Gove Blog.

]]>
As a photographer, you will run into the frustration of noise in their low-light photos and having to remove it at some point. It’s a much of a guarantee as taxes and death. No matter what you do in post processing, it seems like every adjustment you make only makes the noise in your photos worse. As a result, you only grow more frustrated.

Thankfully, we can turn to our secret weapon, Python, to remove noise from our photos. While it’s not well documented, Python has some incredibly powerful image processing libraries. With a proper understanding of the algorithms, we can use Python to remove nearly all the noise from even the grainiest of photos. And to put our money where our mouth is, we’re going to put our Python script up against Adobe Lightroom to see which one can better remove noise from photos.

The Problem with Noise in Low Light Photos

No matter your skill level, whenever you head out to take photos in low light, you probably dream of coming home with a photo that looks like this.

Post-Sunset Light at Arches National Park in Utah

Instead, you come home with a monstrosity like this.

Grainy Post-Sunset Light at Arches National Park in Utah

Despite these two pictures being taken with the same camera less than 20 minutes from each other, why did the first one come out so much better than the first? Yes, post-processing does play a small role in it, but the main culprit is the camera settings and the photo composition. No amount of post-processing can bring back lost data in a photo that’s incorrectly composed. Because the second photo is not correctly composed or exposed, much of the data in the bottom half of the frame is lost.

Let’s compare the two photos.

ParameterFirst PhotoSecond Photo
Time of Sunset (MST)4:57 PM4:57 PM
Photo Timestamp (MST)5:13 PM5:29 PM
Sun AngleSun Behind CameraLooking into Sun
Shutter Speed1/20 sec1/10 sec
Aperturef/4.0f/5.3
ISO Level800800
Focal Length55 mm160 mm
I took both photos with my Nikon DSLR Camera

Poor Composition Leads to Noise in Photos

From the photo metadata, we can easily conclude that the difference between the two shots is indeed the composition. More specifically, it’s the sun angle. When you take a picture looking into the sun, it will be higher contrast than a picture that’s taken with the sun behind you. When taken to extremes, you can actually have data loss at both the dark and light ends of the spectrum.

And that’s exactly the result when you take the photo a half hour vs 15 minutes after sunset. Because the second photo looks into the sunset, being further past sunset exacerbates the increase in contrast. As a result, you need to choose whether you want to properly expose the dark land or the colorful sky. You can’t have both. On the other hand, the first photo is able to capture the full spectrum of light that’s available, resulting in the spectacular dusk colors.

What Causes Noise: A Crash Course in ISO Levels

The ISO level sets how sensitive you camera is to light. Most cameras set the ISO levels automatically by default. The more sensitive your camera is to light, the brighter your photos will be. Lower ISO levels result in sharper images, while high ISO levels lead to grain in your photos.

Exactly how much grain appears in your photos depends on your camera’s sensor size. Professional cameras with large sensors often don’t have much of an issue with grain. On the other end of the spectrum, small or entry-level cameras are much more sensitive to grain because their sensors are so much smaller. Tiny sensors are why cell phone cameras struggle so much in low light. The technology has certainly gotten better over the past five years, but it’s still far from perfect.

On a bright, sunny day, use low ISO levels to keep photos sharp and avoid overexposing them. Alternatively, use high ISO levels for low light or night photography. Under normal conditions, your ISO levels should be between 200 and 1600. However, ISO levels on some very high end cameras can reach as high as 2 million.

Even Professional Image Processors Like Adobe Lightroom Can Only Do So Much to Remove Noise from Your Photos

As powerful as Adobe Lightroom is, it has its limits. You can’t just blindly take photos in low light and expect to turn them into masterpieces with some combination of Lightroom and Photoshop. As we mentioned earlier, no amount of post-processing can recover lost data in your photos. It’s up to you to properly compose your photos and use the correct camera settings.

However, even with proper composition, professional image processors like Adobe Lightroom can only get rid of so much noise. Adobe Lightroom does a spectacular job getting rid of much of the noise in your photos, but you’ll eventually find yourself in a situation where there’s just too much noise for it to handle.

However, where Adobe Lightroom leaves off, our secret weapon takes over.

Python Has Powerful Image Processing Capabilities

It’s not well advertised, but Python has incredibly powerful image processing libraries that as a photographer, you can use to boost both your productivity and income. However, I want to caution that you should use Python as a tool to compliment Adobe Lightroom, not replace it. Being able to write your own scripts, functions, and algorithms in Python to add to the functionalities of Lightroom is incredibly powerful and will set you apart from just about every other photographer.

Indeed, I do my post processing with Adobe Lightroom. Afterwards, I use Python to format, scale, and watermark pictures that I post both to this blog and to the Matt Gove Photo website. When I used to write blog posts that had lots of pictures (and before I had Adobe), it often took me upwards of an hour or more to manually scale and watermark each image. Then I had to make sure nothing sensitive was being put on the internet in the metadata. That all can now be accomplished in just a few seconds, regardless of how many pictures I have. Furthermore, my Python script will automatically remove sensitive metadata that I don’t want out on the internet as well.

You may recall that in some of our previous Python tutorials, we have used the Python Imaging Library, or Pillow, to process photos. Today, we’ll be using the OpenCV library to remove noise from our photos.

How Python Algorithms Remove Noise From Photos

Whenever you write Python code, you should try to understand what built-in functions are doing. This will not only give you a better understanding of what your script is doing, but you will also write code that is faster and more efficient. That’s especially critical when processing large images that require lots of computing power.

Example: Removing Noise from COVID-19 Data

Before diving into our photos, let’s look at a very simple example of removing noise from a dataset. Head over to our COVID-19 dashboard and look at the time series plots of either new daily cases or new daily deaths. Without any noise removal, the plots of the raw data are messy to say the least.

Raw Curves of New Daily COVID-19 Cases in Several Countries

To smooth the data curves and remove noise, we’ll use a moving average. For every data point on the curve, we’ll calculate the average number of new daily cases over the previous seven days. You can actually average as many days as you want, but the industry standard for COVID-19 data is seven days. We’ll plot that 7-Day Moving Average instead of the raw data. The resulting curves are much cleaner and presentable.

New Daily COVID-19 Case Curves, using the 7-Day Moving Average to Remove Noise

People use moving averages more much more than just COVID-19 data. It’s often used to smooth time series in the Stock Market, scientific research, professional sports, and much more. And we’ll use that exact same concept to remove noise in our photos.

How to Average Values with Python to Remove Noise in Photos

There are several ways to go about doing this. The easiest way is if you take several versions of the same shot, lay them on top of each other, and average the corresponding pixels in each shot. The more shots you take, the more noise will be removed. To ensure that your scene does not shift in the frame as you take the shots, use a tripod.

Mathematically, noise is random, so averaging noise pixels will effectively remove the noise. The scene that is actually in your shot does not change, so the non-noise pixels should far outnumber the noise pixels when you calculate the average. As a result, calculating the average removes the noise.

Consider the following equations. For the sake of this argument, let’s say you’re looking at just a single pixel. The actual value of the pixel in the scene is 10. However, in four of your shots, noise is introduced, and the camera records values of 4, 15, 9, and 18. Remember that the average is the sum of the values divided by the number of values.

In your first attempt, you take 10 shots of the scene. How would you do in noise removal?

average = ((6*10) + 4 + 15 + 9 + 18) / 10 = 106 / 10 = 10.6

Not bad, seeing as the actual value of the pixel should be 10. But we can do better. Instead of taking 10 shots of the scene, let’s take 100 instead.

average = ((96*10) + 4 + 15 + 9 + 18) / 100 = 10.06

That’s much better. It may not seem like much, but even just a small change in value can make a big difference for removing noise.

What Does This Method of Removing Noise From Photos Look Like in Python

Believe it or not, we can write the “stacking average” algorithm to remove noise from photos in just 12 lines of Python. We’ll use numpy for the calculations because it can natively store, calculate, and manipulate grids or matrices of data with just a line or two of code. As a result, all of the photo data will remain in the grid or matrix of pixels we’re familiar with. We don’t need to break it down into rows, columns, or anything else.

First let’s make sure you have installed numpy and OpenCV. If you haven’t, you can easily install them with pip. Open a Terminal or Command Prompt and execute the following commands.

pip3 install numpy
pip3 install opencv-python

Next, it’s time to write our Python script. Let’s start by importing everything we need. The cv2 library we’re importing is part of OpenCV.

import os
import numpy as np
import cv2

Second, tell Python which folder the image you’ll be averaging are stored in. Then list their filenames, skipping any hidden files that are in the image directory.

folder = "noise-imgs"
image_files = [f for f in os.listdir(folder) if not f.startswith('.')]

Third, open and read the first image into the average variable using OpenCV. Store pixel data as a numpy floating point number. You’ll use this variable to store image data and calculate the average of the image pixels.

path = "{}/{}".format(folder, files[0])
average = cv2.imread(path).astype(np.float)

Fourth, add all of the remaining images in the directory to you average variable. Don’t forget to skip the first image because we’ve already added it in the previous step.

for f in files[1:]:
    path = "{}/{}".format(folder, f)
    image = cv2.imread(path)
    average += image

Fifth, divide your average variable by the number of images to calculate your average value.

average /= len(image_files)

Finally, normalize the averaged image and output it to a jpeg file. The cv2.normalize() function boosts the quality, sharpens the image and ensures the colors are not dark, faded, or washed out.

output = cv2.normalize(average, None, 0, 255, cv2.NORM_MINMAX)
cv2.imwrite("output.jpg", output)

That’s it. There are only 14 lines of code. It’s one of the easiest scripts you’ll ever write.

Example: Dusk in the Oregon Pines

We’ll throw our Python algorithm a tough one to start. Let’s use a photo of a stand of pine trees in Oregon taken at dusk on a cloudy winter night. Here’s the original.

Original low light photo has plenty of noise

The photo is definitely grainy and really lacks that really crisp sharpness and detail. I don’t know about you, but I’d be tempted to just throw it away at first glance. However, what happens if we let our Python algorithm have a crack at removing the noise from the photo?

Photo after removing the noise with our Python algorithm

That looks much better! I’ll admit, the first time I ran the algorithm, I was absolutely floored at how well it worked. The detail was amazingly sharp and crisp. I unfortunately had to shrink the final image above to optimize it for the web, so the detail doesn’t appear quite as well as it does in the original. For the ultimate test, we’ll put our Python algorithm up against Adobe Lightroom’s noise removal shortly.

A Travel Photography Problem: What Happens If You Only Have a Single Shot and It’s Impossible to Recreate the Scene to Get Multiple Shots?

Good question. This is a common problem with travel photography, and is why I always encourage you to take multiple shots of things while you’re traveling. You never know when you might need them. Unfortunately, the above method really doesn’t work very well in this case. However, there are other ways to remove the noise.

We’ll use the same strategy to remove the noise as we did for the COVID-19 data. But instead of averaging over the previous seven days, we’ll average each pixel or cluster of pixels with the pixels that surround it. However, there’s a catch, here. The more layers of pixels you include in your average, the less sharp your image will be. You’ll need to play around to see what the exact balance is for your specific photo, but the OpenCV documentation recommends 21 pixels.

Thankfully, the OpenCV library has this algorithm built into it, so we don’t need to write it.

cv2.fastNlMeansDenoisingColored(source, destination, templateWindowSize, searchWindowSize, h, hColor)
  • source The original image
  • destination The output image. Must be same dimensions as source image.
  • templateWindowSize Size in pixels of the template patch that is used to compute weights. Should be odd. Defaults to and is recommended to be 7 pixels.
  • searchWindowSize Size in pixels of the window that is used to compute weighted average for given pixel. It’s value should be odd. Defaults to is recommended to be 21 pixels
  • h Luminance component filter component. Bigger h value perfectly removes noise but also removes image details, smaller h value preserves details but also preserves some noise
  • hColor Color component filter component. 10 should be enough to remove colored noise and do not distort colors in most images.

When we run the image through the OpenCV algorithm, it outputs the following.

Sunset at Arches National Park After OpenCV Removed the Noise

The noise is certainly removed, but the image is still very dark and you can see the fuzziness around the edges. To sharpen the image back up, go back into Lightroom and find the original image. Remove as much of the noise from the original image as possible in Lightroom, and then export it. Next, average the OpenCV image and the Lightroom image using the stacking method from the previous section. That will both sharpen the image and brighten the colors.

Sunset at Arches National Park After Final Processing with Python Algorithm

That looks much better than the original photo. Other than a little touch-up post processing in Lightroom, that’s about as much as we can help this photo.

How Does Our Python Script Hold Up Against Adobe Lightroom’s Noise Reduction?

All right, it’s time for the ultimate test. It’s time to see how our Python algorithm does against Lightroom’s noise reduction capabilities. If you read the title of this post, you can probably guess how this went. Turns out it wasn’t even close. Our Python script blows Lightroom out of the water.

Left: Noise Removed from Photo with Adobe Lightroom
Right: Noise Removed from Photo with our Python Algorithm

Despite the results, I want to caution you that this comparison is a bit like comparing apples to oranges. Sticking with the pine tree reference, it would be like cutting a tree down with a chainsaw vs. a hand saw. Because Lightroom only has access to the single photo, it must use the algorithm that takes a cluster of pixels and averages the pixels surrounding it to remove the noise. Do you notice how much sharper the Python image is compared to the Lightroom image? It’s because our Python algorithm has far more resources available to it to remove the noise from the photo. 63 times the resources to be exact. That’s why it’s not exactly a fair comparison.

Lightroom vs. Python Comparison on a Level Playing Field

To level the playing field, forget about averaging over multiple photos to remove the noise. Let’s say we only took one photo of the pine forest in Oregon. As a result, we can use only the single original image. We’ll process it using the same method we did for the sunset at Arches National Park in the above section. When we put it up against Lightroom this time, it’s a much closer contest. However, I still give the edge to the Python algorithm because the final image is noticeably sharper.

Left: Noise Removed with Adobe Lightroom
Right: Noise Removed with Python, without averaging over multiple shots

Want to Try the Python Script Yourself?

If you want to try out any of the Python algorithms we covered in this post, please download the scripts for from out Bitbucket repository.

Conclusion

Removing noise from photos is an endless frustration for photographers at all skill levels. To add insult to injury, high-end image processors such as Adobe Lightroom can only do so much to remove noise. However, with mathematical knowledge of how noise works, we can write an algorithm that does even better than Lightroom. And best of all, it’s only 14 lines of Python code. You can actually apply these algorithms to videos as well, but that’s a discussion for another day.

However, even though we put our algorithm up against Lightroom, we mustn’t forget that as photographers and image processors, Python must be used as a tool to complement Lightroom, not replace it. Because when we pit the two against each other, it’s only us that suffer from reduced productivity and a less effective workflow. If you’d like to boost your productivity by adding Python to your photography workflow, but don’t know where to start, please reach out to me directly or schedule a free info session today. I can’t wait to see what the power of Python can do for you.

The post How to Remove Noise from Photos with 14 Lines of Python…and Blow Lightroom Out of the Water appeared first on Matthew Gove Blog.

]]>
Travel Bloggers: How to Stand Out with Powerful Interactive Maps https://blog.matthewgove.com/2022/02/04/travel-bloggers-how-to-stand-out-with-powerful-interactive-maps/ Fri, 04 Feb 2022 16:00:00 +0000 https://blog.matthewgove.com/?p=3818 Interactive maps are one of the most powerful tools available to travel bloggers today. Unfortunately, far too many travel bloggers today are either using interactive maps incorrectly or not using them to their full potential. As a GIS expert, data scientist, and travel blogger myself, it pains me greatly when […]

The post Travel Bloggers: How to Stand Out with Powerful Interactive Maps appeared first on Matthew Gove Blog.

]]>
Interactive maps are one of the most powerful tools available to travel bloggers today. Unfortunately, far too many travel bloggers today are either using interactive maps incorrectly or not using them to their full potential. As a GIS expert, data scientist, and travel blogger myself, it pains me greatly when I see so many crappy maps on travel blogs. There is so much potential going to waste. As a result, I want to help you, the travel blogger, realize the full potential of your interactive maps. At the very minimum, you’ll see more traffic, retain more visitors, and make your website easier to navigate.

What Makes a Good Interactive Map?

Regardless of what industry you’re in, a good interactive map is easy to understand, offers an intuitive user experience, and draws the user’s focus to the data on the map. One of the best examples of an interactive map is the RadarScope application, which we covered in detail last month in 6 Powerful Weather Applications for Stunning Landscape Photography. If you’re not familiar with it, RadarScope is an application that plots weather radar data, severe weather warnings, and much more on a map.

So how exactly does RadarScope do it so well? When I look at the maps in the screenshots above, I make a few key observations about what makes it such a powerful interactive map, even without having access to its interactivity.

  1. Your eye is immediately drawn to the radar data on the screen.
  2. The basemap is simple enough that you instantly know where the storms are, while at the same time fading into the background and not distracting you from the data on the map.
  3. RadarScope’s chosen color scheme is easy to understand because it’s the industry standard for the weather and meteorology field.
  4. The design of RadarScope’s user interface is timeless. The last two screenshots in the above gallery are from the El Reno (31 May) and Moore, Oklahoma (20 May) tornadoes in 2013. The remaining screenshots were taken between 2017 and 2021.

You Can Bring That Same User Experience to Your Travel Blog Without Breaking the Bank

Thankfully, there are plenty of tools and applications available today to bring a similar mapping experience to your travel blog. Best of all, many are free and open source, so you don’t have to spend your hard-earned cash on expensive licensing fees. However, before we look at solutions, let’s have a look at the problem.

Too Many Travel Bloggers’ Interactive Maps are Not Actually Fully Interactive

In order to fully understand the problem so many travel bloggers run into, let’s first look at the definition of interactive.

Interactive: allowing a two-way flow of information between a computer and a computer-user; responding to a user’s input.

Oxford Dictionary

Armed with that definition, have a look at what you’ll find on far too many travel blogs. From the home page, you click on a link or button to the interactive map. You see a simple map that looks something like this screenshot. Some of the countries may be shaded to indicate that the blogger has traveled there.

A Map of world with countries shaded is not an interactive map
You’ll find maps that look like this on a lot of travel blogs

If you hover over a country, it’ll often show the country’s name and maybe a count of the number of blog posts, photos, or videos the travel blogger has created. However, if you click on a country, you’ll just be brought to another page with a list of post titles. In the best case scenario, you’ll also see a featured image and the first 20-40 words of the post, much like our All Posts page.

However, this still leaves me asking one question. If you have a map whose only purpose is to redirect visitors off of said map, why even have the map at all?

How Can Travel Bloggers Make Their Maps Interactive?

First and foremost, if you’re going to add a feature to your blog or website, it should serve more of a purpose than just redirecting visitors off of it. Your visitors should be able to gather all of the information they need without leaving the map. There is one exception, however. If you’re trying to display lengthy content, such as an entire blog post, don’t try to put the entire post in a pop-up window on the map. Nobody in their right mind is going to scroll through all of that.

Instead, you want to include key details and a link to the full blog post to make a fully interactive map. For a blog post, you’ll want to include at least four things.

  • Title of the post
  • A summary of the post or the first 20-25 words of it
  • The post’s feature image
  • A link to the full post
  • Anything else that’s relevant and important, such as the date, author, or location

Example: The Matt Gove Photo Visual Media Map

To best demonstrate a fully interactive map, let’s have a look at the Matt Gove Photo Visual Media Map. Instead of blog posts, the map includes datasets to display all of our photos and videos on a map. Notice how it includes all five requirements for full interactivity. As a user, you can easily explore our photos and videos on a map without having to leave the map. In addition, you can click on the link in the pop-up window to view the full album or video.

Best GIS Solutions for Travel Bloggers to Create Interactive Maps

As recently as 10 years ago, getting professional-quality interactive maps meant shelling out hundreds, if not thousands of dollars every year in GIS software licensing fees. Even worse, there were very few online GIS programs to choose from back then.

Thankfully, that has all changed. Today, you there are an plenty of free online mapping programs available. Many of these programs are both incredibly powerful and easy to set up. While it’s certainly not a requirement, I highly recommend investing in a developer to install, connect, and integrate the maps on your website. They’ll be able to connect your maps directly to your database. As a result, new content will automatically be added to your maps, allowing them to effortlessly scale with your business. It’ll cost more up front, but with a good developer, you’ll save money in the long run.

We’d love to help you get set up with your maps. If you want to discuss your project further or get a free quote to add maps to your travel blog, please get in touch with us today. Or if you’re still just kicking tires, please feel free to browse our catalog of GIS products and services.

Google Maps or Bing Maps

If you’re just starting out or are looking for a simple solution, Google or Bing Maps are great options! Both platforms allow you to create high-quality maps and embed them on your website free of charge. And best of all, you don’t need a developer. Instead, you’ll just copy and paste a short block of code into your website or blog.

Unfortunately, the simplicity of both Google and Bing Maps leave them with some downsides. Most notably, if you have a dynamic dataset or high traffic volumes, you’ll run into issues. Neither platform is built to display large datasets. As a result, you’ll struggle to scale your application and will run into high API fees to generate the basemaps as your organization grows.

Mapbox

Mapbox is a direct competitor of both Google and Bing Maps, but it offers so much more. As a result, I typically recommend that my clients use Mapbox over Google or Bing. Mapbox gives you much finer control over your mapping application, allowing you to scale it both up and down as your business evolves. And best of all, it’s completely free to use, unless you have more than 50,000 map loads per month.

Mapbox map of Boston, in a light grey color scheme
Screenshot of a Simple Mapbox Map of Boston, Massachusetts

However, my favorite Mapbox feature is its use of vector tiles, which allows you to display huge amounts (read: gigabytes) of data that load and respond extremely fast.

  • Fully customizable maps
  • Much friendlier pricing than Google or Bing
  • Supports both proprietary and open source data formats
  • Offers a software development kit to add your own functionalities and customizations
  • Developer optional to use maps or embed them on your website

Leaflet

Leaflet is a simple, yet powerful open source JavaScript library that displays two-dimensional maps on your website or blog. Because it’s hosted on your server, you don’t need to worry about API fees, regardless of how much or how little traffic you get. It’s lightweight, fast, powerful, and completely customizable. Furthermore, it has an extensive library of plugins and extensions if you need additional functionality. If you don’t know JavaScript, you’ll need a developer for the initial set up of your maps. You can easily connect Leaflet to nearly any type of database or data repository. As a result, Leaflet maps will easily scale with your business once it’s set up.

A popup box on a sample Leaflet interactive map
Screenshot of a Data Point on a Leaflet Map

Thankfully, Leaflet requires very little maintenance once you get it up and running. In fact, I tell my clients that it’s often more cost-effective to pay for Leaflet maintenance as you need it instead of paying a recurring monthly maintenance fee. Yes, there are obviously exceptions to that rule. However, for the vast majority of people, Leaflet is an extremely cost-effective way to add high-quality maps to your website or blog.

Cesium

Like Leaflet, Cesium is an open source JavaScript library that creates powerful 3D maps to “unleash the power of 3D data”. Their maps are engineered to maximize performance, precision, and experience. With Cesium, it often feels like there is no limit when it comes to what you can do with a map. In fact, Cesium also includes a timeline, so you could make the argument that its maps are four dimensional instead of three.

Furthermore, they’ve even created their own 3D vector tile format that lets you load enormous datasets in seconds. For example, check out Cesium’s demo that loads 3D models of nearly every building in New York City. It’s fast, fluid, and responsive. For additional demos, have a look at Cesium’s Use Cases. You’ll find examples from many different industries, applications, and regions.

Screenshot of a cockpit from a flight simulator built on Cesium's 3D mapping technology
Someone even built a flight simulator on the Cesium platform

You can get an incredible amount of power and functionality out of Cesium’s free base functionality. For the average travel blog, the free functionality is probably more than you need. However, if you want to harness its full potential, you should at least look into some of the paid add-ons for Cesium. Those paid add-ons will streamline your workflow and optimize your data. As a result, your users will ultimately have a better experience.

Terria

If you’re trying to decide between Leaflet or Cesium, why not use both? Originally developed as an open source platform for the Australian Government, Terria lets your users choose whether they want to view a two or three dimensional map. And you can probably see where this is going. Leaflet powers Terria’s two dimensional maps, which Cesium is behind its three dimensional maps.

The best feature of Terria, however, is its user interface. Easily organize and browse through a huge number of datasets. It uses Cesium’s 3D data optimization to ensure your map remains fast and responsive, even if your datasets are massive. Use Terria’s slider to compare datasets side-by-side. It even includes a feature for you to build stories with your data and share them with your audience.

I use Terria for all of my mapping needs, and also recommend it for most of my clients. Its power and responsiveness across all devices, including mobile phones, coupled with its flexibility and minimal programming required to set it up make it the optimal platform for me. My users and clients have never complained about being confused using Terria, and are often impressed at how easy it is to analyze huge amounts of data. And best of all, I can set it up so it scales up and down as I need without needing hardly any maintenance.

If you want your travel blog to stand out from the rest, adding fully interactive maps with Terria is one of the easiest and most cost-effective way to do so. To learn more or get started, please get in touch with us or browse our online resources.

ESRI ArcGIS Online

If you have a complex dataset, but would prefer not to hire a developer, ESRI’s ArcGIS Online may be the best solution for you. Yes, it does have licensing fees, but you’ll get much of the functionality of the other applications we’ve discussed without needing a developer to set them up for you. Like the other platforms, ArcGIS online can easily handle large numbers of complex datasets, and plot those data on maps that need just a copy and paste to embed in your website. Plus ESRI is widely considered to be the industry standard for anything related to GIS and maps. If anything goes wrong for you, they have excellent documentation and support.

If you’re looking for a real-world example of ArcGIS Online in action, you’ve probably seen them already. Since the COVID-19 pandemic began, most dashboards that display maps of COVID-19 data use ArcGIS online.

Interactive map on Johns Hopkins University's COVID-19 dashboard
ESRI ArcGIS Online powers many COVID-19 Dashboards, including the one by John’s Hopkins University

Summary

PlatformFreeAPI FeesDimensionsDeveloperDynamic Data
Google/Bing MapsYesOptional2D OnlyNot RequiredNo
MapboxYes> 50K loads/mo2D OnlyOptionalYes
LeafletYesNot Required2D OnlyRequiredYes
CesiumYesNot Required3D OnlyRequiredYes
TerriaYesNot Required2D & 3DRequiredYes
ArcGIS OnlineNoN/A2D OnlyNot RequiredYes

Travel Bloggers, Take Your Interactive Maps to the Next Level

Once you have your new interactive map set up on your website or blog, simply adding a link to it is not enough. In addition, you should strategically embed them on different pages of your website to give your users the most immersive experience. For example, you’ll find the Matt Gove Photo Visual Media map embedded both on the home page of this blog and the main photo gallery page on the Matt Gove Photo website, in addition to being embedded above. I’ll continue to add maps as we go forward, too.

Interactive map embedded on the Matt Gove Photo website
You’ll find the Matt Gove Photo Visual Media Map strategically embedded across our websites

To figure out where to embed your interactive maps, have a look at your website’s analytics. Are there pages that have a lot of page views? Is there a specific page people are navigating to that the map could benefit? Are your visitors getting confused and leaving your website instead of navigating somewhere the map could help? Is there a logical place for your maps in your navigation or sales funnel?

Finally, as a travel blogger, you shouldn’t plot just your blog posts on the interactive map. Geotag photo albums, videos, social media posts, guides, fun activities, scenic drives, and much more. Don’t be afraid to make multiple maps, either. Try to use a platform like Terria or ArcGIS Online that organizes your datasets in a logical manner and makes it easy to both add and remove data from the map. If that’s not an option, don’t overwhelm your users with too much data on a single map. That’s one of the best ways to drive visitors off of your website and directly into the arms of your competitors.

Conclusion

Fast, professional quality interactive maps are one of the best ways travel bloggers can stand out from the crowd. Interactive maps are easy and cost-effective to implement and maintain. They’re also incredibly effective at retaining your visitors’ engagement and keeping them on your website. It boggles my mind why so many travel bloggers haven’t taken full advantage of the incredible potential interactive maps present to both grow your audience and keep your existing followers coming back for more.

Are you ready to take the next steps with interactive maps and bring your website or travel blog to the next level? As avid travelers and data science experts who specialize in online GIS and mapping applications, we’d love to help you take that next step in your journey. I invite you to please browse our catalog of GIS and mapping services. Then, get in touch or book a free info session with us to discuss your specific project. We can’t wait to hear from you.

Top Photo: Chapman’s Peak Drive on the Matt Gove Photo Scenic Drives Map
Cape Town, Western Cape, South Africa

The post Travel Bloggers: How to Stand Out with Powerful Interactive Maps appeared first on Matthew Gove Blog.

]]>
How to Boost Your GIS Productivity with Python Automation in 5 Minutes https://blog.matthewgove.com/2021/11/05/how-to-boost-your-gis-productivity-with-python-automation-in-5-minutes/ Fri, 05 Nov 2021 16:00:00 +0000 https://blog.matthewgove.com/?p=3385 Python Automation is one of the most powerful ways to improve your GIS workflow. In the past, many tasks in traditional GIS applications have had minimal support for writing your own code, and often required crude hacks to install obscure libraries. As Python has rapidly grown in both functionality and […]

The post How to Boost Your GIS Productivity with Python Automation in 5 Minutes appeared first on Matthew Gove Blog.

]]>
Python Automation is one of the most powerful ways to improve your GIS workflow. In the past, many tasks in traditional GIS applications have had minimal support for writing your own code, and often required crude hacks to install obscure libraries.

As Python has rapidly grown in both functionality and popularity, it is now widely supported across, and even built into many GIS platforms. Adding Python scripting to your GIS workflow can accomplish tedious hours-long tasks in seconds. Full automation of your GIS processes with Python will free you up to focus the more important aspects of your project, regardless of what industry you’re in.

Automate Your Desktop GIS Application

Did you know that ESRI ArcGIS and QGIS are both written in Python? As a result, Python automation integrates effortlessly with both GIS platforms. The Python libraries for each platform are incredibly powerful, fast, and easy to use.

However, be aware that the Python libraries for ArcGIS and QGIS are specific to each platform. If you ever decide to change platforms, you’ll need to rewrite all of your Python scripts.

QGIS Window with Python Console

I recommend starting small to get your feet wet with GIS Python automation. Start by automating the symbology and color of your data before diving into data manipulations, calculations, and analysis. Then you can start tackling more complicated processes, such as file conversions, modifying layers, switching projections, and much more.

Automate Your Web-Based GIS Application

Automating web-based GIS applications with Python is not quite as seamless as with ArcGIS or QGIS. However, you can easily argue that it’s even more powerful. Web-based GIS applications are a bit more complicated than desktop-based platforms. In addition to the GIS software, you often need special servers and databases that are designed specifically for geospatial data.

Thankfully, this increased complexity also means that there are more opportunities for automation. I use Python automation on nearly all of my web-based GIS applications. I don’t have tutorials for all of these yet, but here are a few of my favorites.

Python Automation Updates Our COVID-19 Dashboard Every Day

Remote Sensing Automation with Python

Most sensors these days come with Python libraries when you buy them. You should absolutely take advantage of those libraries. With Python, you can calibrate and configure the sensors exactly how you want them, not the way the manufacturer wants them.

In May of 2019, I installed sensors on the weather station I have at my house. The weather station runs on a network of Raspberry Pi’s. A Python script reads the data from each sensor, QA/QC’s it, and records it in the weather station’s database. If a sensor goes offline or makes a bad reading, the weather station pulls the data from the National Weather Service.

  • DIY Weather Station: Building a Solar Radiation Shield from Scratch
  • Wiring Power and Internet to the Sensors
  • Installing the Data Logger and Connecting the Sensors
  • Database Configuration and Programming the Sensor Readings
  • Troubleshooting a Sensor Gone Awry
https://youtube.com/watch?v=twZNWximYd0

Take your remote sensing automations even further. Use Python GeoPandas to plot your data on a map. Perform a high-level data analysis using pandas or matplotlib. You can easily automate the whole process or leave yourself as much manual control as you wish.

Data Entry Automation with Python

Without data, you don’t have a GIS application. You just have a map. Furthermore, geodatabases and data repositories come in all different shapes and sizes. Thankfully, Python can easily handle all of these data types and schemas thanks to its robust and dynamic data science libraries.

Python’s pandas library is one of the most powerful data analysis libraries available in any programming language. The fact that it’s free and open source is even more incredible, given how expensive licenses to proprietary software can be. pandas can handle just about any data format and size you throw at it.

However, pandas on its own does not support any geographical or location-based data. Enter Python’s GeoPandas extension of the pandas library. GeoPandas gives you the ability to analyze geospatial data and generate maps using the same tools you have in pandas. Easily populate a geodatabase or assemble a repository of any supported GIS format, including shapefiles, CSV, GeoJSON, KMZ, and much more. For more information, please visit our collection of GeoPandas tutorials.

Python GeoPandas can create beautiful maps without a GIS application

Data Analysis Automation with Python

With over 12 years of experience in professional data analysis, I know firsthand how tedious having repetitive tasks can be. Instead of the monotony of having to repeat those tasks over and over, why not automate them with Python? After all, Python developers created both pandas and matplotlib for that exact purpose. In the context of GIS, you can fully or partially automate many common tasks.

  • Repetitive tasks to prepare and/or format the data for analysis
  • Create maps of different areas using the same data parameters
  • Generate multiple maps of the same areas using different data parameters
Python has plenty of powerful data analysis libraries available for geospatial data

How to Trigger Your GIS Automation

To reach the nirvana of full automation, a Python script alone is not enough. You also need to automate the automation. Fear not, though, triggering your automation is the easy part. You have two options to choose from.

Trigger Your Automation to Run at a Set Time

The majority of GIS automations run at the same time every day. Our COVID-19 dashboard is the perfect example of this. We have a Python script that downloads the COVID-19 data from the Johns Hopkins University GitHub repository, parses it, and adds it to our database. Unfortunately, our web hosting plan does not allow us to fully automate the script, so we automate it on a local machine and then upload the database to the production server.

Scheduling the automation on your computer or server is quick and easy. On Linux and Mac OS, use the crontab command to schedule a cron job, which is a job that runs at fixed dates, times, and/or intervals. Alternatively, use the Task Scheduler on Windows. Both schedulers give you full flexibility to schedule jobs exactly when you want them to run.

Trigger the Script to Run When a Specific Event Occurs

Alternatively, not all jobs run at a specific time or interval. Have a look at the map of the Matt Gove Photo albums and videos. There is no logical need to run the job at a set time or interval. Instead, we update the map whenever we add a photo album or video to the database. As soon as the new album or video lands in the database, it automatically adds the data to the map.

In Python, the simplest way to trigger your GIS automation is a call to a function that runs the automation. For example, let’s look at the logic of adding photos and videos to the Matt Gove Photo map. In its simplest form, the logic for adding a photo album would look something like this.

# Add a Photo Album to the Database
add_photo_album_to_database(album_parameters)

# Once the database is updated, update the map
update_map(album_parameters)

This example is very oversimplified, but you get the point. For even finer control, use conditional logic and loops for precisely triggering your scripts exactly when you want.

Don’t Forget to Test Your Automation Scripts Before Putting Them into Production

We all make this mistake at one point or another. You beam with pride when you finish your automation script, and schedule it to run for the first time overnight. The next morning, you log in eagerly expecting to see the output of your automation. Instead, you see nothing, or even worse, you see an error message. You facepalm yourself because you forgot to test everything!

The best way to test your automation is to write a few quick unit tests once you finish your script. If you’re unfamiliar with a unit test, it tests individual units of code in your script. You tell the test the expected outcome for a given parameter, and then run that parameter through the block of code. If the script output matches the expected output, the test passes. If not, it fails.

For example, let’s say you programmed a calculator application. To set up a unit test for addition, execute 2 + 2 with the calculator, and see if you get 4. Repeat the process with unit tests for subtraction, multiplication, and division. The best part about unit tests is that you can run a lot of them in a short amount of time. If you’ve written them correctly, they’ll tell you exactly where in the script any problems are.

Use Creativity and Innovation in Your Python Automation

Once you get your feet wet with GIS automation using Python, keep automating. I encourage you to get creative and come up with new, innovative ways that will improve your workflow even further. The sky really is the limit when it comes to automation.

Conclusion

The days of managing bloated and complicated workflows with expensive software are a thing of the past. Python automation is the future, not just in GIS, but also in nearly every industry out there. Start out with simple tasks to whet your palette. Once you get a taste of it, don’t be afraid to tickle that creative or innovative itch we all have. You’ll be amazed at the amount of time and money it can save. Let us help you get started today.

Top Photo: View of Death Valley from Sea Level
Death Valley National Park, California – February, 2020

The post How to Boost Your GIS Productivity with Python Automation in 5 Minutes appeared first on Matthew Gove Blog.

]]>
How to Automate Region Mapping in TerriaJS with 49 Lines of Python https://blog.matthewgove.com/2021/10/15/how-to-automate-region-mapping-in-terriajs-with-49-lines-of-python/ https://blog.matthewgove.com/2021/10/15/how-to-automate-region-mapping-in-terriajs-with-49-lines-of-python/#comments Fri, 15 Oct 2021 16:00:00 +0000 https://blog.matthewgove.com/?p=3334 A little over a month ago, we examined the benefits of using region mapping in your TerriaJS applications. Region mapping allows you to reduce your GIS application’s data usage by over 99%, permitting you to display massive datasets on two and three-dimensional maps that load quickly and are highly responsive. […]

The post How to Automate Region Mapping in TerriaJS with 49 Lines of Python appeared first on Matthew Gove Blog.

]]>
A little over a month ago, we examined the benefits of using region mapping in your TerriaJS applications. Region mapping allows you to reduce your GIS application’s data usage by over 99%, permitting you to display massive datasets on two and three-dimensional maps that load quickly and are highly responsive.

Example region mapping in TerriaJS
Our COVID-19 Dashboard Map Makes Extensive Use of Region Mapping in TerriaJS

Despite the power and benefits region mapping offers, setting it up can be tedious, time consuming, and rife with type-o’s if you attempt to do it manually. This can be particularly frustrating if you have a large number of regions you want to map. Thankfully, there’s a much easier way. With just 49 lines of Python code, you can generate region maps of any size in just seconds, freeing up valuable time for you to focus on more important tasks.

What You’ll Need

You’ll need a few items to get started with your TerriaJS region mapping automation.

  • The ESRI Shapefile or GeoJSON file that you used to generate your Mapbox Vector Tiles (MVTs) for the region mapping
  • The Python script you’ll write in this tutorial
  • A Terminal or Command Prompt

What is a Region Mapping File

In TerriaJS, a region map consists of two JSON files.

  1. The actual region map
  2. The region mapping configuration file

The Python script we’re writing in this tutorial generates the actual region map. The region map tells TerriaJS the order that each polygon appears in the vector tiles. The configuration file instructs TerriaJS which vector tile parameters contain the region’s unique identifier, name, and more. You can easily write a short Python script to generate the configuration. However, unless you have a lot of region maps you’re generating, I find that the configuration is so short, it’s easier to do manually.

Convert all Shapefiles to GeoJSON Before Automating Region Mapping

If you have ESRI Shapefiles, convert them to GeoJSON before automating your region mapping. We do this for two reasons.

  1. Python can read and parse GeoJSON files natively. To parse shapefiles, you’ll need a third-party library such as GeoPandas.
  2. Mapbox’s Tippecanoe program, which generates the Mapbox Vector Tiles we use for region mapping, requires files to be input in GeoJSON format.

The GeoJSON should contain at least three properties for each feature. We covered these properties in detail in our previous article about region mapping, so I won’t repeat them here. You’re welcome to add as many properties as you want, but it should at the bare minimum contain the following three features.

  • A Feature ID, or FID.
  • A unique identifier you’ll use to identify the feature in the CSV data files you load into Terria.
  • The name of the feature

Most of our map tiles actually contain several unique identifiers that can be used. For example, countries actually have two sets of ISO (International Organization for Standardization) standards, plus a United Nations code that can be used to uniquely identify them. We can use any of these three, plus our own unique identifier to map them to our Mapbox Vector Tiles.

CountryISO Alpha 2 CodeISO Alpha 3 CodeUN Numeric Code
AustraliaAUAUS036
BrazilBRBRA076
CanadaCACAN124
FranceFRFRA250
MexicoMXMEX484
New ZealandNZNZL554
United StatesUSUSA840
Unique Country ID Examples

All right, let’s dive into the Python code.

First, Input Python’s Built-In json Library

The real magic of region mapping in TerriaJS is that all of the files are just JSON files, which are compatible with every popular programming language today. As a result, all we need to do the automation is Python’s json library. The json library comes standard with every installation of Python. We just need to import it. We will also be using Python’s os library to ensure the correct paths exist to output our region mapping files.

import json
import os

First, Write a Python Function to Extract the Feature ID from each Feature in the GeoJSON

This is because you need to go down several layers into the GeoJSON and we need this functionality a lot. It’s best practice to avoid string literals in programming, so we’ll use a function to extract the Feature ID from any given feature in the GeoJSON file.

def fid(f):
    return f["properties"]["FID"]

Define Your Input Parameters

We define the GeoJSON file name, the layer name in the TerriaJS region mapping configuration (regionMapping.json), and the property we’ll use as the unique identifier in our region mapping. Even if your MVT tiles have multiple unique identifier, you may only choose one for each region map. You’ll need to generate a second region map if you want to use multiple unique identifiers.

GEOJSON = "world-countries.geojson"
LAYER = "WORLD_COUNTRIES"
MAPPING_ID_PROPERTY = "alpha3code"
OUTPUT_FOLDER = "regionIds"

If you prefer not to have to manually edit the Python script every time you want to change files, you can easily update the Python script to extract this information from the filename or receive it through command line arguments.

Define the Output Path for Your Region Map File

I like to do this right away because it uses the input parameters. This both gets it out of the way so we don’t need to deal with it later and eliminates the need to scroll up and down looking for variable names if we were to define these at the end. We’ll structure our output paths so they can just be copied and pasted into Terria when we’re done. No renaming or reshuffling of files required.

geojson_filename = GEOJSON.replace(".geojson", "")
output_json_filename = "region_map-{}.json".format(geojson_filename)
output_fpath = "{}/{}".format(OUTPUT_FOLDER, output_json_filename)

In this example, the output filepath or our region mapping file will be regionIds/region_map-world-countries.json.

Read the GeoJSON into Python

Because GeoJSONs are just a specific type of JSON file, we can use Python’s built in json module to read and parse the GeoJSON file.

with open(GEOJSON, "r") as infile:
    raw_json = json.load(infile)

Sort the GeoJSON features by Feature ID

When you convert the GeoJSON to MVT tiles, Tippecanoe sorts the GeoJSON by Feature ID. For the region mapping to work correctly, the feature in the region map must appear in the exact same order as they appear in the Mapbox Vector Tiles. If they’re not in the exact same order, your data will be mapped to the wrong features in TerriaJS. What’s particularly insidious about this issue, is that it will appear as if your data is mapped to the correct county, even though it’s not.

When I first tried to set up region mapping for the World Countries vector tiles, I did not have the features in the right order. Data for the United States was mapped to Ukraine and labeled as Ukraine’s data. France’s data showed up in Fiji, and New Zealand’s data appeared to be Nepal’s. And that’s just to name a few. Except for a few countries at the top of the alphabet that start with “A”, this issue plagued every country. Once I sorted the GeoJSON features by Feature ID, the problem magically went away.

raw_features = raw_json["features"]
features = sorted(raw_features, key=fid)

Note here that we use the fid function we defined above to identify the Feature ID in the sorted() function.

TerriaJS Region Maps are just Arrays of Sorted Feature ID’s

To generate the region map for TerriaJS, all we need to do is just loop through the sorted features and create an array of the unique ID for each feature. Remember that the unique ID is different from the Feature ID. For world countries, TerriaJS comes with the Alpha 2 Codes built into it. For this tutorial, we’ll use the ISO Alpha 3 code as our unique identifier, which we defined in the MAPPING_ID_PROPERTY variable in the use input. If you’ve forgotten, the alpha 3 code is just a 3-letter code that identifies each country. For example, use “USA” for the United States, “CAN” for Canada, “JPN” for Japan, and so forth.

We’ll generate the region map with a simple for loop.

region_mapping_ids = []

for f in features:
    properties = f["properties"]
    region_map_id = properties[MAPPING_ID_PROPERTY]
    region_mapping_ids.append(region_map_id)

Assemble the full TerriaJS Region Mapping JSON in a Python Dictionary

TerrisJS region mapping files are breathtakingly simple. They require three parameters.

  • layer: The name of the layer in the TerriaJS Region Mapping configuration (regionMapping.json). We defined it above with the LAYER variable in the user input.
  • property: The name of the unique identifier in your vector tiles that you’ll use in the CSV files you load into Terria. For the world countries, we’re using the alpha2code identifier. We defined this in the user input using the MAPPING_ID_PROPERTY variable.
  • values: This is the the array of sorted feature ID’s we created in the previous section

It’s important to note that Python does not actually support JSON format. Instead, when you read a JSON file into Python, it actually converts the JSON into a Python dictionary. When we export the dictionary to JSON format, Python just simply does the conversion in the opposite direction.

Anyway, the TerriaJS region mapping JSON should look like this as a Python dictionary.

output_json = {
    "layer": LAYER,
    "property": MAPPING_ID_PROPERTY,
    "values": region_mapping_ids,
}

Also, don’t forget to create the output directory if it doesn’t exist. Your Python script will crash without it.

if not os.path.isdir(OUTPUT_FOLDER):
    os.makedirs(OUTPUT_FOLDER)

Finally, Write the TerriaJS Region Mapping JSON to a .json File

Thanks to Python’s json module, we can output the region mapping file with just a couple lines of code.

with open(output_fpath, "w") as ofile:
    json.dump(output_json, ofile, indent=4)

If you did everything correctly, the region mapping JSON you just created should look like this.

{
    "layer": "WORLD_COUNTRIES",
    "property": "alpha3code",
    "values": [
        "AFG",
        "ALB",
        "DZA",
        "AND",
        "AGO",
        "ATG",
        ...
    ]
}

But we’re not quite done, yet!

Add Your New TerriaJS Region Mapping to the Configuration File

The final step is to add your new region map to the TerriaJS Region Mapping configuration file. By default, the configuration file is located at data/regionMapping.json. However, if you can’t find it, it’s defined in the config.json file at the root of the Terria application. You are more than welcome to automate this, too, but I find that it’s so simple, it’s often easier to just do manually.

The configuration file instructs TerriaJS how to interpret each region map. You’ll need to include several parameters.

ParameterDescription
layerNameThe name of the layer in the Mapbox Vector Tiles. If you can’t remember it, check your vector tiles’ metadata.
serverThe URL from where your Mapbox Vector Tiles are served
serverTypeThe type of files the server is serving. For this tutorial, use MVT, which stands for “Mapbox Vector Tiles”.
serverMinZoomThe minimum zoom level of the vector tiles
serverMaxNativeZoomThe maximum zoom level the vector tiles support natively
serverMaxZoomThe maximum zoom level the vector tiles support
regionIdsFileThe path to the TerriaJS Region Mapping JSON we created in this tutorial
regionPropThe name of the property in the vector tiles that contains the unique identifier we’re using in the region map.
aliasesAny column headers in the CSV data file that TerriaJS should interpret as the unique identifier of your region map
descriptionA description of the region map
bboxThe bounding box of your vector tiles, in the format [west, south, east, north]
namePropThe name of the property in the vector tiles that contains the name of each feature

Using the layer we defined in the LAYER variable as the JSON key, your regionMapping.json configuration file should look like the following.

{
    "regionWmsMap": {
        ...
        "WORLD_COUNTRIES": {
            "layerName": "world-countries",
            "server": "https://yourvectortileserver.com/worldcountries/{z}/{x}/{y}.pbf,
            "serverType": "MVT",
            "serverMinZoom": 0,
            "serverMaxNativeZoom": 3,
            "serverMaxZoom": 8,
            "regionIdsFile": "data/regionIds/region_map-world-countries.json",
            "regionProp": "alpha3code",
            "aliases": ["alpha3code", "country_id", "COUNTRY_ID"],
            "description": "World Countries",
            "bbox": [
                -179.99999999999999999999999,
                -85,
                179.999999999999999999999999,
                85
            ],
            "nameProp": "name"
        },
        ...
    }
}

Create a Dummy CSV File to Test it Out

The funnest part of any project is seeing it all come to life once you’re done. To do this, create a dummy CSV file to test that your region mapping actually works. Pick a bunch of countries at random, assign them some random values as a dummy parameter, and see if they show up on the map.

alpha3codeValue
USA7
CAN4
DEU15
THA12
AUS9
BRA3

To load the file into TerriaJS, just click on the upload button at the top of the workbench, next to the “Browse Data” or “Explore Map Data” button. If the region mapping is working properly, you should see your data appear appear on the map.

Our dummy CSV data displayed on a choropleth world map
The Dummy CSV Data on a World Map

Conclusion

Region mapping is one of the most powerful and efficient ways to display enormous amounts of data in TerriaJS. Automating the region mapping process only saves you valuable time and makes your application even more powerful.

While manually region mapping feature sets such as the 50 US states or the roughly 200 world countries may initially seem manageable, it rapidly becomes a nightmare once you try to scale it up. Sticking just within the United States, what if instead of the 50 states, you were mapping America’s more than 3,000 counties? Our COVID-19 Dashboard map does just that. Or even worse, the United States has over 41,000 postal codes and more than 73,000 census tracts. Can you imagine having to assemble those region maps manually, or the opportunity for type-o’s manually entering tens of thousands of data points?

Instead, save yourself the time, money, and hassle. We’ve made the Python script available for free on Bitbucket so you can configure region maps of any size in TerriaJS in just seconds. And if you ever run into issues, we’re always here to help you with any questions you may have. Happy mapping!

Top Photo: Snow-Capped Sierra Nevada Provide a Spectacular Backdrop for Lake Tahoe’s Brilliant Turquoise Waters
Meeks Bay, California – February, 2020

The post How to Automate Region Mapping in TerriaJS with 49 Lines of Python appeared first on Matthew Gove Blog.

]]>
https://blog.matthewgove.com/2021/10/15/how-to-automate-region-mapping-in-terriajs-with-49-lines-of-python/feed/ 1
How to Use Weather to Take Amazing Landscape Photos https://blog.matthewgove.com/2021/09/17/how-to-use-weather-to-take-amazing-landscape-photos/ Fri, 17 Sep 2021 16:00:00 +0000 https://blog.matthewgove.com/?p=3233 As many of you know, chasing tornadoes and severe storms during my tenure as a meteorology student at the University of Oklahoma heavily influenced both my photography style and my quest for adventure. As a former storm chaser, I believe that there is never a bad time for landscape photography. […]

The post How to Use Weather to Take Amazing Landscape Photos appeared first on Matthew Gove Blog.

]]>
As many of you know, chasing tornadoes and severe storms during my tenure as a meteorology student at the University of Oklahoma heavily influenced both my photography style and my quest for adventure. As a former storm chaser, I believe that there is never a bad time for landscape photography. You just have to know how to use weather to your advantage when you compose your landscape photos.

Weather can be an incredibly powerful way to set the mood and tell your story. Indeed, you can use weather not just in your landscape photos, but also in other types of photography, as well as videography. While photography is primarily a visual medium, when executed properly, use of weather in your photos will stimulate other senses as well, such as sound, smell, and feel.

A grey, snowy scene might conjure up a cozy feeling of sitting around a warm fire with the smell of hot coffee or hot cocoa wafting through the room. On the other hand, a picture of a bright and sunny tropical beach bursting with vibrant colors puts you in a relaxing mood. Close your eyes and you’ll be able to feel the warm, gentle breeze and smell the salty air coming off the ocean. You don’t just want your viewer to see the scene in your photos. You want them to experience it.

Make a Specific Weather Feature the Subject of Your Landscape Photos

There can be a fine line between weather and landscape photography. And I’ll be the first to admit that I’ve toed that line more times than I can remember. While it may seem like everyone has their own definition these days, I prefer to keep things simple. If the landscape is the subject of the photo, it’s a landscape photo. Likewise, if the weather is the subject of the photo, it’s a weather photo.

So what kind of weather features can you use as the subject of your landscape photos? Turns out, just about anything. The only weather feature that really doesn’t work is a cloudless, sunny day. I would argue that no matter how hard you try to make the cloudless, sunny day the subject of your photo, your viewers’ eye will always be drawn to the landscape. However, I find that some weather features tend to perform better than others.

  • Lightning
  • Tornadoes
  • Severe Thunderstorm Clouds and Cloud Formations
  • Snow
  • Heavy Wind
  • Fog and Mist

And that’s just to name a few. The good news is that no matter where in the world you are, you have both landscapes and weather. You’ll need to know what the best photo opportunities are based on the landscape, season, and typical weather patterns. I certainly wouldn’t be trying to get pictures of snowy, majestic mountains in Texas or pictures of fog and mist in Arizona.

Example #1: Go All-In and Transform Your Landscape Photos into Weather Photos

If you have a homogeneous landscape or a landscape that leaves a little something to be desired, you’ll want to go for the straight weather photo. Anyone who has gone storm chasing in Tornado Alley has used this strategy. Coupled with the fact that these photo ops are restricted to such a small geographic area for only a few months of the year, it’s why photos of supercells and tornadoes so often leave you in complete awe.

Let’s look at a few examples of true weather photos. The landscapes in these photos all have one thing in common. Can you figure out what it is?

EF-3 Tornado in Kansas
EF-3 Tornado near Harper, Kansas on 19 May, 2012
Supercell near Chickasha, Oklahoma
Supercell Thunderstorm near Chickasha, Oklahoma on 30 May, 2013
El Reno Supercell on 31 May, 2013
The 31 May, 2013 El Reno, Oklahoma Supercell. Some believe this storm may have produced the strongest tornado ever to hit earth in modern times.
A severe thunderstorm approaches Amber, Oklahoma at sunset.
A Severe Thunderstorm Approaches Amber, Oklahoma on 30 May, 2012

Were you able to spot what the landscape in all three photos have in common? They are all homogeneous landscapes that are, on their own, actually quite boring. It’s the weather in each photo that gives it its pop and pizazz. If we take the weather out of those photos and just look at the landscape, you won’t feel much of a reaction. As a result, your viewer won’t be able to get that fully immersive experience that truly great photographs can offer.

Oklahoma landscape under blue skies, void of any weather
Oklahoma can certainly be beautiful, but these scenes leave me with one reaction: Meh!

Example #2: Use Weather to Subtly, yet Powerfully Draw Out Reactions and Emotions in Your Landscape Photos

On the other hand, what if you’re somewhere that has particularly beautiful or dramatic landscapes? You’re probably a little hesitant to completely abandon the landscape in your composition like we did with straight weather photography. I don’t blame you!

Instead, you want to leave the landscape as the subject of the photo and use weather to set the mood, trigger an emotion, or tell a story. To illustrate how to properly do this, let’s take a trip down to the white sandy beaches of Florida. You should feel two very different emotions when you look at these photos, which were taken within just a few miles of each other.

Secluded beach near St. Pete Beach, Florida
Near St. Pete Beach, Florida
Severe thunderstorm clouds over Tampa Bay, Florida
Near the Sunshine Skyway Bridge in St. Petersburg, Florida

How did you feel when you looked at those photos? The first photo should leave you feeling relaxed, secluded, and tucked away. You may even feel refreshed at the thought of cooling off in the inviting waters. On the other hand, the second photo should get the adrenaline pumping a little. You probably feel a bit threatened or exposed, too, like you need to get to shelter.

We’ve only just scratched the surface of showing how powerful weather can be in landscape photos. You’ve got two photos with very similar landscapes that would not appear boring or homogenous on their own. Yet at the same time, two very different weather phenomena leave your viewer feeling two very different reactions to each respective photo.

Before we move onto the next section, have a look at some more examples of using weather to draw out reactions and emotions in landscape photos. Pay special attention to how you’re reacting to seeing each photo. Then use those feelings to inspire your own landscape photography.

Shelf cloud near St. Petersburg, Florida
Tierra Verde, Florida
Summer monsoon storms over Puerto Penasco, Sonora, Mexico
Puerto Peñasco, Sonora, Mexico
A haboob overtakes mountains near Organ Pipe Cactus National Monument, Arizona
Why, Arizona
Snow and clouds obscure the view into the Grand Canyon
Grand Canyon National Park, Arizona – looking into the Canyon

Use Color Theory to Your Advantage

The premise of color theory is simple. You want to use complimentary colors that not only look stunning together, but can also provoke reactions and emotions that align with your brand’s mission and values. You can keep color theory as simple as just looking at a color wheel, or your can dive into the fascinating mathematics behind it. We covered it all in full detail back in July, so I’ll refer you there for the details about color theory.

That being said, do recall that there are four bases that make up the basis of color theory.

Basis# of ColorsExplanation
Complimentary Colors2Opposite (180°) from your primary color on the color wheel
Adjacent Colors3Two colors offset 30° to 45° in each direction from your primary color on the color wheel
Triad Colors3Two colors offset 135° to 150° in each direction the your primary color on the color wheel
Tetrad Colors4Form a rectangle on the color made up of your primary color, complimentary color, one adjacent color, and one triad color

Keep Color Theory in Mind When Composing Your Photos

Have you ever seen photos from Havasupai Falls in Arizona? The brilliant red rocks provide a stunning backdrop to the brilliant turquoise waters in the falls. Yet when you look at photos of the emerald waters of the Colorado River inside of Grand Canyon, it just doesn’t generate the same reaction and emotions that Havasupai does. Why is that? They’re equally beautiful places.

The reason lies in color theory. The red rocks and turquoise waters at Havasupai falls are nearly perfect complimentary colors. You can actually mathematically prove that just the turquoise waters alone at Havasupai falls will look more stunning against the red rocks than the emerald waters of the Colorado River.

Red and teal complimentary colors opposite each other on a color wheel
Complimentary colors fall opposite each other on the color wheel. The turquoise waters of Havasupai is the near perfect complimentary color to the red rock walls inside Grand Canyon.

While I have never actually been to Havasupai Falls, I have been to the confluence of the Little Colorado River, which has the same brilliant turquoise waters as Havasupai. Have a look at the following pictures yourself. They were taken within about an hour of each other. Which one do you like better?

Brilliant turquoise waters cascade over rocks in the Little Colorado River
Turquoise waters of the Little Colorado River inside Grand Canyon National Park
The emerald waters of the Colorado River as it snakes through Grand Canyon National Park are not complementary colors to the red rocks, so the colors don't pop as much.
Emerald waters of the Colorado River inside Grand Canyon National Park

The Psychology of Color

I am no psychologist, but research has proven that different colors invoke different emotions. Indeed, businesses use the psychology of color in their branding and marketing. It’s very subtle, but when used correctly can be very powerful. It’s all done in the name of portraying your brand exactly how you want to.

ColorEmotions
YellowOptimism, Clarity, Warmth
OrangeFriendly, Cheerful, Confidence
RedExcitement, Youthful, Bold
PurpleCreative, Imaginative, Wise
BlueTrust, Dependability, Strength
GreenPeacful, Growth, Health
GreyBalance, Neutral, Calm

For full details, here’s a really good article about the psychology of color.

Use Overcast Skies and Winter Landscapes for a Dramatic Pseudo-Black and White Effect

Embrace the lack of color on grey and cloudy days. While color theory can make those brilliantly colorful scenes dazzle, the lack of color can be equally as beautiful. As good as the lack of color looks on thick overcast days, it really shines in winter scenery. A little bit of color poking through a fresh blanket of snow can be spectacular.

Fresh snowfall on Cape Cod, Massachusetts voids the landscape of color.
Cape Cod, Massachusetts
Snow falls in the Kaibab National Forest near Flagstaff, Arizona
Kaibab National Forest near Flagstaff, Arizona

While you can certainly go full black and white if you want, I prefer to use the little bit of color in those images to my advantage. Use it to highlight the subject of your image or to accent the scene around the edges, like I did in the above photos.

You can also use light to highlight parts of your image in the total absence of color. Look for a situation where you have sunlight shining through broken clouds that shines on your subject like a spotlight. It should really stand out against a dark and colorless backdrop. Add a little color to your subject, and it’s pure magic.

The setting sun illuminates spires inside the Grand Canyon after a winter storm
Grand Canyon National Park, Arizona

I do want to point out one important detail. Even though the background and foreground are dark and colorless, you can still both see it and tell what it is. This important detail gives your photo both depth and context. Without it, you won’t generate the reactions or evoke the emotions you had hoped.

Experiment with Different Times of Day When Taking Landscape Photos. But Even With the Addition of Weather, the Golden Hour is Still King.

Armed with basic knowledge of weather and color theory, there is no bad time for landscape photography. I don’t ever want to hear an excuse that you can’t take landscape photos in the middle of the day because the shadows are too harsh. Go out and take them anyway. You’ll be surprised at what you get. Even more, in the worst case scenario, just delete them if they’re no good. Nothing lost, nothing gained.

You can't capture the brilliant turquoise colors of Lake Tahoe in low light
Lake Tahoe is Gorgeous No Matter What Time of Day You Photograph It. You won’t get those brilliant blues and turquoises in low light.
Desolate landscapes inside Death Valley National Park, California
You can’t put the “death” in Death Valley without the powerful searing midday sun

I also encourage you to try taking landscape photos at night. You can add some really cool effects to your photos using long exposures at night. If you’re in a really dark area, try looking beyond the weather and into outer space. Try to capture the Milky Way Galaxy in the sky or use a really long exposure to show the Earth’s rotation in the stars. On the other hand, if you’re just beginning, start out with a classic cityscape at night. You can’t go wrong with the glistening skyline of your favorite city lit up at night.

The San Francisco skyline glistens on a clear night.
San Francisco, California

The Golden Hour Remains Second-to-None

While you can certainly make the argument that you can take beautiful landscape photos at any time of day, the Golden Hour remains the best time of day for landscape photography. No amount of weather can change that.

If you’re unfamiliar with the Golden Hour, it refers to the last hour before sunset and the first hour after sunrise. During that hour, the low sun casts a warm glow across the landscape. Long shadows add relief, texture, depth, and drama to your photo.

Not surprisingly, some of the best landscape and weather photos I’ve ever taken came during the Golden Hour. While I consider myself very fortunate to have such beautiful landscapes in Arizona, the Golden Hour photos I’ve taken elsewhere rival the Arizona photos more often than not. I could go on, but I’ll let the photos speak for themselves.

The setting sun casts a warm glow on Gloss Mountain State Park in Oklahoma
Gloss Mountains State Park, Oklahoma
Cape Cod sunset as the remnants of Hurricane Ida clear the region
Cape Cod, Massachusetts
Low evening light illuminates a fresh snowfall along Interstate 17 in Arizona.
Yavapai County, Arizona
The rising sun illuminates virga over the McDowell Mountains in Scottsdale, Arizona
Scottsdale, Arizona
Soft early morning light in Palo Duro Canyon State Park near Amarillo, Texas
Palo Duro Canyon State Park – Amarillo, Texas

A Dramatic Sky and a Dramatic Landscape Are Spectacular Together

This one is simple math. The best of your weather composition plus the best of your landscape composition equals spectacular unrivaled beauty.

Monsoon showers provide a dramatic sky over the rugged landscape of the Superstition Mountains in Arizona.
Summer Monsoon Storms in the Superstition Mountains, Arizona
Monsoon storms approach the Mogollon Rim in Arizona
The Mogollon Rim in Arizona during Monsoon Season
Low sunlight shines on Arizona's White Tank mountains as a storm clears out of the area.
White Tank Mountains near Surprise, Arizona

Use Long Exposures to Add Motion to Wind, Rain, and Snow in Your Landscape Photos

Because lighting for landscape photography cannot be controlled in a studio, using long exposures can risk permanently losing data to overexposure. To combat overexposure, shoot during the Golden Hour using a small aperture and/or filters. Once you lose data to overexposure, no amount of post-processing can recover it.

If you’re using certain types of weather to improve your landscape photos, showing motion is critical to your viewer being able to get the maximum experience. Unfortunately, showing motion in weather often subjects you to shooting in heavy wind. As a result, you really need to be using a tripod if you want any kind of viable results. Trying to hold the camera steady just won’t cut it. If you don’t have a tripod, try to use an elevated surface, post, or tree limb to hold your camera steady. It’s not perfect, but it’s a lot better than nothing.

To properly show motion in your landscape photos, only the objects that are actually in motion should appear to be moving. Everything else should be steady. If you try to show everything in motion, you’ll just wind up with a blurry photo. It’s the same as when you try to please everybody, you end up pleasing no one.

It’s generally okay to show small amounts of motion in objects that sway back and forth in the wind. I’m talking about the ends of tree limbs, flags, waves, moving vehicles, and the like here. If your photos depict entire trees and buildings in motion, you’re not doing it right.

Here are a few examples of photos that show motion correctly. I also want to point out that some of these certainly fall into the category of weather photos as opposed to landscape photography.

Heavy snow pounds Woodneck Beach in Falmouth, Massachusetts during a blizzard
Falmouth, Massachusetts
Wind-blown snow swirls on a desolate road during a blizzard
Falmouth, Massachusetts
Hurricane conditions drive rain and seawater horizontally as a powerful cold front slams St. Petersburg, Florida
St. Petersburg, Florida

After the Storm Can be a 24-Hour Long Golden Hour

When I lived in Oklahoma, one thing that really struck me was just how spectacular the weather was after a major severe weather event. Never was this more true than following the 20 May, 2013 EF-5 tornado that tore through Moore, Oklahoma. A few days after witnessing that disaster unfold firsthand, I was sitting in my back yard reflecting on what had happened. The sun was out, temperatures were cool, and the weather was absolutely perfect.

As I reflected on the tornado, it dawned on me how some of the most breathtaking landscape photo ops occur during the first 24 hours immediately following a storm. This is exceptionally true following blizzards and winter storms. You can’t beat a fresh blanket of snow on any landscape. I’ll let the photos speak for themselves.

Ice flows in Vineyard Sound following a blizzard.
Woods Hole, Massachusetts
Skies clear over Grand Canyon National park following a winter storm
Grand Canyon National Park, Arizona
Quissett Harbor is frozen over after a blizzard.
Quissett Harbor – Falmouth, Massachusetts

You can also find some extended Golden Hours leading up to storms. In the case of severe thunderstorms, you’ll find amazing photo ops out in front of the storm as it approaches, too. This is what the entire concept of storm chasing is based off of, so I could write an entire post on it. However, that’s a discussion for another day.

Conclusion

Weather is one of the most powerful and effective ways to inject new life, mood, and story into your landscape photos. From dramatic scenes to vibrant colors to the beautiful Golden Hour, there’s something for every landscape photographer’s style. No matter where you are in the world, you have both weather and landscapes at your fingertips to perfect your craft.

The strategy to using weather to get good landscape photos is similar to storm chasing. A little knowledge of weather and forecasting will put you ahead of the competition. You’ll know where the best spots to target for the best landscape photos are instead of just having to guess. You won’t always get it right, and it won’t happen overnight, but your landscape photos will go from good to amazing.

Want even more photography tutorials? Please checkout out our full collection of photography guides and sign up for our email list (in the sidebar at the top of the page), where you’ll receive free photography tutorials directly in your inbox.

Top Photo: An EF-3 Tornado Tears Across an Open Prairie During the Golden Hour
Harper, Kansas – May, 2012

The post How to Use Weather to Take Amazing Landscape Photos appeared first on Matthew Gove Blog.

]]>
How to Set Up and Automate Region Mapping in Terria https://blog.matthewgove.com/2021/09/10/how-to-set-up-and-automate-region-mapping-in-terria/ Fri, 10 Sep 2021 16:00:00 +0000 https://blog.matthewgove.com/?p=3222 In today’s media-rich internet, load times are critical to your web application’s success. There is no industry for which that rings true more than the online mapping and GIS community. In the past, even small to medium-sized datasets were notorious for crippling web-based GIS applications and crashing web browsers. Thankfully, […]

The post How to Set Up and Automate Region Mapping in Terria appeared first on Matthew Gove Blog.

]]>
In today’s media-rich internet, load times are critical to your web application’s success. There is no industry for which that rings true more than the online mapping and GIS community. In the past, even small to medium-sized datasets were notorious for crippling web-based GIS applications and crashing web browsers. Thankfully, the leaders of the online GIS community have come up with a solution that I used to reduce data usage in my COVID-19 Map by 99.92%. And that’s just for one country. Today, you’re going to learn how to achieve similar results by setting up region mapping in Terria.

What is Region Mapping?

Region mapping is the process of using unique identifiers to map a dataset to a separate map geometry. While this geometry can be any polygon, line, or point on a map, it is most often some kind of physical or political boundary, ranging from state and country borders down to census tracts, neighborhoods, and property lines. The benefits of region mapping are profound for web-based GIS applications such as Terria and Cesium.

  • Load map geometries once in region mapped datasets vs every data point in datasets that do not use region mapping
  • In Terria, your dataset is stored in CSV format, which can opened with everyday tools such as Microsoft Excel
  • Vector tiles used in region mapping are typically between 1% and 10% the size of most other GIS formats, including Shapefiles, GeoJSON, and KML/KMZ.
  • Reuse vector tilesets over multiple datasets to easily scale your application up and down. The geometries I use to track COVID-19 can be reused to track weather, elections, Census data, population, and more.
  • Region mapping only loads the visible part of the map geometry in Terria. Without vector tiles, you must load the entire geometry, regardless of whether or not it’s visible.

Region Mapping Performance in Terria

So just how much of a performance boost do you get using region mapping? Let’s look at the actual performance of loading the geographies of the Canadian provinces that we use in our COVID-19 map. Keep in mind that these numbers are for loading the geometry only. They do not load any COVID-19 data.

ParameterGeoJSONRegion Mapping/Vector Tile
Entire Geometry Size141 MB26 MB
Whole Country Overview on Map141 MB643 kB
Whole Country Overview Load Time (100 mbit/sec)11.28 sec0.05 sec
Provincial Overview: Ontario141 MB281 kB
Ontario Overview Load Time (100 mbit/sec)11.28 sec0.02 sec

As you can see, the region mapping wins hands down. This effect only gets compounded once you add the COVID-19 data. If you’re not using region mapping, the map geometry needs to be loaded for every data point you have. When you take that 141 MB GeoJSON and multiply it by 550-plus days of the pandemic, you’re looking at about 70 GB of data for just the geometry alone! And that number gets bigger with each day that passes. With region mapping, you only load the 643 kB of geometry to see the overview of Canada, regardless of how many days the pandemic drags on for.

If it weren’t for region mapping, we would not be able to publish our COVID-19 maps because the large datasets would crash your browser.

I do want to point out that GeoJSON currently does not support time-series data. However, if you convert it to a format that does, such as CZML, you’re still looking at similar sizes and load times for the geometry.

What You’ll Need to Set Up Region Mapping in Terria

The Terria developers have thankfully made it very easy to set up region mapping. You’ll need a few tools to do it.

  • Your map geometry, in either GeoJSON format or a format that can be easily converted to GeoJSON, such as an Esri Shapefile.
  • A means to convert your geometry to GeoJSON. I recommend either a GIS program or Python GeoPandas.
  • Your favorite text editor
  • [Optional] Python, if you want to automate the process. We’ll cover automating this process in detail in a future tutorial.

Step 1: Configure Your GeoJSON or Shapefile

Before we convert our GeoJSON into vector tile format, we need to make sure each feature has the necessary parameters for region mapping. At the very minimum, each feature needs to have a feature ID and a unique ID that can easily identify it.

Set a Numeric ID for Each Feature in the GeoJSON

The feature ID is simply an incremental number starting at zero or one. We’ll use the feature ID to tell Terria the correct order that each feature appears in the vector tileset. Without this feature ID, your features will not display the correct dataset on the map unless they are in numerical or alphabetical order based on your ID. For example, let’s stick with the COVID-19 data and look at US States. Your GeoJSON is in alphabetical order by state name, and you’re using the 2-letter postal abbreviation as the unique ID.

Here’s where things go awry without a feature ID. If your GeoJSON is in alphabetical order by state name, Maine comes before Maryland. Likewise, Maryland comes before Massachusetts. However, using the postal abbreviations, that order changes. Massachusetts (MA) comes first, followed by Maryland (MD), and then Maine (ME). Because you specified the postal abbreviations as the unique ID for region mapping, Terria assumes that they are in alphabetical order by postal abbreviation. However, you have actually set them in alphabetical order by state name.

As a result, Terria will incorrectly determine that Maine’s data belongs to Massachsetts and vice-versa. If you clicked on Maine on the Map, the data table would be labeled as Maine, but it would actually display Massachusetts’ data. With a feature ID, you can actually tell Terria that the correct order of postal abbreviations is ME, MD, and then MA. We’ll circle back to this shortly.

Once you get your GeoJSON into the order that you want it to be in, go through an assign an incremental Feature ID to each feature in the GeoJSON. If you’re using the US States in alphabetical order by name, Alabama would be 1, Alaska would be 2, Arizona would be 3, and so on.

Include a Unique Identifier You’ll Use in Your Datasets

You’re more than welcome to use your Feature ID in the datasets. However, I really don’t recommend doing that because you won’t be able to remember them. Instead, assign them a standardized ID, such as an ISO, FIPS, or postal code. Let’s say you want to plot some data for the New England States. If you had to update the dataset several years down the road, which identifiers would be easier to recognize when you open the data file?

  • ME, NH, VT, MA, RI, CT
  • 21, 30, 46, 19, 39, 7

Interestingly, there’s still a problem using just the postal abbreviations as your unique identifier. What happens if you’re working across multiple countries? You’re bound to run into a conflict at some point where two countries use the same abbreviation. Take Massachusetts as an example. There are 23 countries that use “MA” as a state or provincial abbreviation.

To avoid those conflicts, simply use the ISO 3166-2 codes to identify each state. The ISO codes are standardized worldwide and prepend the 2-letter country abbreviation to the state or province abbreviation to make it a unique identifier worldwide. Even if you only plan to operate in just one country, you should still use the ISO codes. You never know when you may need to expand.

ISO 3166-2 CodeState or ProvinceCountry
US-MAMassachusettsUnited States
ES-MAMálagaSpain
BR-MAMaranhãoBrazil
CD-MAManiemaDem. Republic of Congo
JO-MAAl MafraqJordan

Our Recommended GeoJSON Configuration

Our region mapping files consist of four properties.

  • Feature ID
  • ISO Code or other standardized unique identifier
  • Unique numerical identifier that’s tied to our master geodatabase
  • The feature or entity’s name

We include two unique identifiers because it gives us flexibility in how we structure our datasets. While we primarily use the standardized identifier, there are certainly instances where it’s more beneficial to use the once that’s directly linked to our master geodatabase. If you aren’t using a master database, by all means omit that property.

When you put it all together, here’s an example of what the properties for Massachusetts look like in our GeoJSON.

{
    "FID": 19,
    "iso3166_2": "US-MA",
    "state_id": 4239,
    "name": "Massachusetts"
}

Step 2: Convert the GeoJSON to Mapbox Vector Tile Format

To convert the GeoJSON file to vector tile format so you can use it for region mapping in Terria, you’ll need to use a tool called Tippecanoe. Mapbox created Tippecanoe specifically for converting GeoJSON files to vector tiles, but it comes with a catch. It’s Unix based, so it only runs on Mac OS or Linux. It does not work on Windows. You can install Tippecanoe for free from GitHub.

Once you have Tippecanoe installed, it only takes one command from your command line to generate the vector tiles. We use the following command to generate vector tiles of state and provincial boundaries:

tippecanoe -z10 -e states --drop-densest-as-needed mexico-states.geojson -l mxstates

So what does this all mean? Let’s break it down. Please consult the Tippecanoe documentation or reach out to us for further details. We strongly recommend you standardize your naming conventions across all vector tile properties so they’re consistent and easy to reference in the future.

CommandMeaning
tippecanoeUse the Tippecanoe program
-z10Include zoom levels from 0 to 10 in the vector tile set
-e statesOutput raw vector tile files to a folder called “states”
--drop-densest-as-neededDrop the least visible features at each zoom level as needed to reduce file size
mexico-states.geojsonThe path to the GeoJSON we want to convert to vector tiles
-l mxstatesThe name of the layer you’ll reference in the region mapping in Terria

Upload Your Vector Tiles to a Mapping Server

Finally, you’ll want to upload your newly created vector tiles to a mapping server. However, be aware that they will not work “out-of-the-box” if you upload them to a standard web host. However, you can configure standard web hosts to serve vector tiles. We’ll cover setting up a mapping server in a future tutorial. In the meantime, if you want to just upload your vector tiles and be done with them, put them in an Amazon S3 bucket, which is configured to serve map tiles by default.

Step 3: Create Your Region Mapping File For Terria

In this step we will create the actual map that tells Terria which unique identifiers correspond to which geometries. The region map is stored in a JSON file. Creating the region map is very prone to type-o’s and human error, so I highly recommend automating this step with Python. We’ll cover automation in a future tutorial. Before we begin, you’ll need a few items from previous steps.

  • The name of the layer in your vector tiles from Step 2
  • Your unique identifier from Step 1 (not the Feature ID)
  • The order that each feature appears in the GeoJSON from Step 1

Remember the Feature ID we discussed in Step 1? If you followed our advice, you put the feature in the GeoJSON in numerical order by that Feature ID. To generate your region map, all you have to do is sort your GeoJSON by Feature ID and pull your unique identifiers out of the GeoJSON in that same order. It’s that simple.

Recall in Step 1 that we had a GeoJSON of US States sorted Alphabetically by state name. We used the ISO 3166-2 codes, which are based on postal abbreviations, as our unique identifier. To generate the region map, simply list the ISO 3166-2 codes for each state in alphabetical order by name. Here’s our region map showing the preserved alphabetical order of Maine, Maryland, and Massachusetts by name. I omitted the rest of the states to save space.

Example Using US State Geometries

{
    "layer": "usstates",
    "property": "iso3166_2",
    "values": [
        ...
        "US-KY",
        "US-LA",
        "US-ME",
        "US-MD",
        "US-MA",
        "US-MI",
        "US-MN",
        ...
    ]
}
ParameterDefinitionDefined In
layerLayer Name of the Vector Tileset, defined with the -l flag in TippecanoeStep 2
propertyThe key of your unique identifier you defined in the GeoJSONStep 1
valuesYour unique identifiers, in the exact order in which their features appear in the GeoJSONStep 1

If you haven’t already, create a folder called data in the root of your Terria application. Inside that folder, create another folder called regionIds. Save your region map in that regionIds folder. You can call it whatever you want, but I recommend naming it something that you can easily identify. For the US States name it something like region_map-us-states.json.

Step 4: Create or Update Your Terria Region Mapping Configuration

Now that we’ve created our region map, we need to tell Terria both to use it and how to use it. We’ll use a JSON file to provide Terria with our region mapping configuration. Terria actually comes with a default region mapping configuration for Australia, but I find it’s much easier if we just define our own instead of trying to add to Terria’s.

First, open the data folder you created in the root directory of Terria at the end of Step 3. Inside, create a file called regionMapping.json. This file will store the region mapping configuration for our Terria application. Open the regionMapping.json file in your favorite text editor. You’ll paste a key/value pair into it for each vector tileset you wish to use for region mapping. Set the keys so they’re easy to identify. In our COVID-19 map, we use keys such as US_STATES, US_COUNTIES, CA_PROVINCES, and WORLD_COUNTRIES.

Example Using US State Geometries

{
    "US_STATES": {
        "layerName": "usstates",
        "server": "https://yourmaptiledomain.com/us-states/{z}{x}{y}.pbf",
        "serverType": "MVT",
        "serverMinZoom": 0,
        "serverMaxNativeZoom": 3,
        "serverMaxZoom": 10,
        "regionIdsFile": "data/regionIds/region_map-us-states.json",
        "regionProp": "iso3166_2",
        "aliases": ["ISO3166_2", "US_STATE_ID"],
        "description": "US States",
        "bbox": [
            -179.999999999999,
            18,
            179.999999999999,
            72
        ],
        "nameProp": "name"
    }
}
ParameterDefinitionDefined In
layerNameLayer Name of the Vector Tileset, defined with the -l flag in TippecanoeStep 2
serverThe URL to your map tile serverStep 2
serverTypeSet to “MVT”, which stands for Mapbox Vector TilesN/A
serverMinZoomThe minimum zoom we defined when we created the vector tileset in TippecanoeStep 2
serverMaxNativeZoomThe maximum zoom level the server supports nativelyN/A
serverMaxZoomThe maximum zoom we defined when we created the vector tileset in TippecanoeStep 2
regionIdsFilePath to the region map JSON fileStep 3
regionPropThe key of your unique identifier that you defined in the GeoJSONStep 1
aliasesAdditional column headers in your dataset that Terria will recognize as your unique identifier. If you want the Terria’s drag and drop feature to work, one of these must be set to a unique value.Step 1
descriptionDescription of your region mapN/A
bboxBounding box that contains the map geometry, in degrees of latitude and longitude. It has the format [west, south, east, north].N/A
namePropThe key of the GeoJSON feature’s property that contains the feature’s nameStep 1

Step 5: Link Your CSV Data to the Region Map in the Terria Initialization File

The final step completes the link between your dataset and the vector tiles. We’ll update your initialization file to tell Terria which region map to use for each dataset in your catalog. You can find your initialization files in Terria’s init directory. All you have to do is add your CSV dataset to your initialization file. At the very minimum, you’ll need the following.

{
    "name": "United States: COVID-19 by State",
    "type": "csv",
    "url": "data/us-covid19-by-state.csv"
    "tableStyle": {
        "regionVariable": "iso3166_2",
        "regionType": "US_STATES",
        "dataVariable": "New Cases",
        "columns": Outside the Scope of this tutorial; Refer to Terria Documentation
    }
}
ParameterDefinitionDefined In
nameThe name under which your dataset will appear in Terria’s data catalogN/A
typeSet to “csv” because your data is in CSV formatN/A
urlThe URL where the CSV file containing your data is locatedN/A
tableStyle.regionVariableThe key of your unique identifier that you defined in the GeoJSONStep 1
tableStyle.regionTypeThe key of our region map in the Terria Region Mapping configurationStep 4
tableStyle.dataVariableThe header of the column that contains the data you want Terria to display when it initially loads your datasetN/A
tableStyle.columnsData formatting that’s outside the scope of this tutorial. Please consult the Terria documentation for details.N/A

If you’ve set everything up right, you’ll see each state get colored in when you use the ISO 3166-2 codes in your CSV file.

Example CSV Snippet of COVID-19 Data

ISO3166_2DateConfirmedDeadNew CasesNew Deaths
US-CA2020-07-01238,6816,1697,44987
US-CA2020-07-02246,5506,2657,86996
US-FL2020-07-01158,9973,5506,56345
US-FL2020-07-02169,1063,61710,10967
US-TX2020-07-01172,3862,5089,25550
US-TX2020-07-02179,1112,5476,72539
US-HI2020-07-019261890
US-HI2020-07-0194618200
US-NY2020-07-01394,07932,04362511
US-NY2020-07-02394,95432,06487521

Conclusion

Region mapping with vector tiles is the most powerful and efficient way to display massive datasets in web-based GIS platforms such as Terria and Cesium. Region mapping can seem daunting and even a little intimidating the first time you try it. Trust me, it took me a long time to figure it out, too, when I first started working with it.

If you’re struggling with region, please don’t hesitate to reach out to me personally or leave a comment below. The Terria developers are generally pretty responsive as well. Just a few small fractions of a second can be the difference between your mapping application taking off and failing. Are you willing to take that chance with slow, bloated file formats?

Top Photo: Region Mapping for the US, Canada, and Mexico on our COVID-19 Map
September, 2021

The post How to Set Up and Automate Region Mapping in Terria appeared first on Matthew Gove Blog.

]]>