My Google Map Blog

Tag: contours

Higher resolution contours with Mapzen altitude tiles

by Timothy Whitehead on Sep.05, 2016, under 3D Models, Argentina, Australia, Brazil, California, Denmark, England, Germany, Google Earth News, Google Earth Tips, Google Sky, Google maps, Hawaii, Indonesia, Ireland, Italy, Japan, Kenya, Mexico, Natural Landmarks, Netherlands, Sightseeing, Street Views, USA

We recently did several posts about drawing contours using altitude data from different Altitude API services. The first version used the Google Maps Elevation API and the second used Mapzen’s elevation API. The biggest problem was that the API’s are throttled, in Google’s case, to stop abuse and in Mapzen’s case due to limited server resources. Mapzen recommended that we instead switch to using a different method for getting the altitude data from them. They provide the option to get the altitude data in the form of tiles similar to the tiles used in various online maps, but with just altitude data. So, we decided to try it out.

We expected some improvement in speed, but it turned out to be a much faster method than we expected and works very well. The tiles are 256 x 256 points of data and we use one to four tiles, depending in the location chosen. The previous method using the elevation API took about 40 seconds to retrieve 100 x 100 data points, but the new method gets all the data in a couple of seconds despite getting many more data points. In fact we found it was so fast and because it was allowing us to get so much more data, what was taking the time was calculating the contours. So we did some work on optimising that code and managed to get that quite a bit faster too. It can still take a little time if you ask for too many contours close together.

We tested it on Rio de Janeiro and discovered that Mapzen’s elevation data is better than Google Earth’s default layer for Rio. We discussed in this post the poor quality of Google Earth’s elevation data for Rio by comparing it to the 3D data. Mapzen assures us that all their elevation data is open data, so Google might want to look into the discrepancies and update their data. There are probably other areas where Google Earth’s data is better quality, as Google has access to a number of different data sources for elevation data, some of which are not in the public domain.


In Google Earth with 3D imagery turned off, Sugarloaf Mountain is entirely at sea level, but the Mapzen data results in reasonably accurate contours of it.


The faster data access allows us to draw more detailed contours than before.

Note that we automatically zoom in or out depending on the size of the area you choose. We could, if if we choose produce much higher resolution contours in most instances although it would take a lot longer to calculate. We chose not to as this is just a ‘for fun’ project that we haven’t really found a use for. If any of our readers has a specific use for it and does require higher resolution contours, then let us know in the comments and we will consider adding that option.

Using it is similar to last time. Just draw a polygon of the area you are interested in, save it as a KML, upload it here, select the desired options then click ‘Draw contour’.

Create KML
Proportional
Curves (experimental)
Mode:
Altitude: m above sea level
Contour every: m

The post Higher resolution contours with Mapzen altitude tiles appeared first on Google Earth Blog.

Comments Off :, , more...

Improving our contour algorithm

by Timothy Whitehead on Aug.25, 2016, under 3D Models, Argentina, Australia, Brazil, California, Denmark, England, Germany, Google Earth News, Google Earth Tips, Google Sky, Google maps, Hawaii, Indonesia, Ireland, Italy, Japan, Kenya, Mexico, Natural Landmarks, Netherlands, Sightseeing, Street Views, USA

Last week we featured a tool for drawing contours which uses the Mapzen altitude API. We used a very simple algorithm called ‘Marching Squares’ that we found on Wikipedia. However, as GEB reader Боби Димитров pointed out in the comments, if you try to use too low a resolution altitude grid relative to the number of contours you want, you end up with something looking like abstract art:

The Marching Squares algorithm is remarkably simple. We just check every altitude from the grid obtained from the Mapzen API and colour it red or green based on whether it is above or below the altitude of the contour we wish to draw. Then we draw lines separating the two colours from the mid-points of the rectangles in the grid as shown below:

However, we realised that if between a red and green dot rather than using the mid-point, we check the altitudes of the points relative to our contour altitude and then use a point proportionally closer to the point closest to our contour altitude, we end up with a much better result:


All the settings were the same as the ‘abstract art’ sample above, except we used proportional ‘mid-points’ on our squares.

And best of all, it only required changing one line of code!

We have also tried smoothing out the contours using this open source code. It generally works well, but it tends to result in some unwanted loops, so we probably need to look for a different curve algorithm.

Our next step will be to use a different technique to access the elevation data from Mapzen, as suggested by them in the comments. If successful, it should allow much faster access to the elevation data – and thus higher resolutions will be possible.

The changes so far have been added as options in last week’s post.

The post Improving our contour algorithm appeared first on Google Earth Blog.

Comments Off :, more...

More fun with contours

by Timothy Whitehead on Aug.18, 2016, under 3D Models, Argentina, Australia, Brazil, California, Denmark, England, Germany, Google Earth News, Google Earth Tips, Google Sky, Google maps, Hawaii, Indonesia, Ireland, Italy, Japan, Kenya, Mexico, Natural Landmarks, Netherlands, Sightseeing, Street Views, USA

Last week we had a look at drawing contour lines using the Google Maps Elevation API. Because of restrictions on what you are allowed to do with Google’s elevation data, we chose not to create KML files from it. We have since talked to another elevation API provider, Mapzen and they assure us that they use open data from USGS and NOAA and we may do whatever we like with it.

Google’s elevation data, as used in Google Earth is higher resolution in many locations than the Mapzen data because Google also has access to the USGS and NOAA data, but have supplemented it with other sources that are not as open.

Here is an example of what is possible with the new version of our tool:

To try it out with default settings, just click the ‘Draw Contour’ button and see what happens. The default settings should take about 30 seconds to complete. When it is done, it shows the result in the Google Map below as well as downloading a KML file, so you can view the contours in Google Earth.

To use it with your own settings, draw a polygon in Google Earth of the approximate area you are interested in, save it as a KML then select it below. If you do not select a KML file then it will default to using an area in British Columbia, Canada that we selected for its very mountainous terrain.

You can choose how many rows and columns of altitude data to obtain. The Mapzen elevation API limits the number of queries you can make in a given time to prevent individual users from degrading the overall system performance, so very high resolutions take a long time. Remember that doubling the rows and columns will take four times as long to complete.

Selecting ‘Show Altitude Grid’ only works in conjunction with the ‘Single contour’ mode. It displays the grid of the altitudes that were obtained from the Mapzen API and shows them in red if they were above the selected altitude, or green if they were below the selected altitude. Zoom in to see how they relate to the contour line.

[ Update: Also see this post regarding improvements we made to the algorithm. ]

Create KML
Proportional
Curves (experimental)
Show Altitude Grid
Rows:
Columns:
Mode:
Altitude: m above sea level
Contour every: m

If you don’t like the styling of the contour lines in the KML, you can change them in Google Earth from the properties of the containing folder rather than having to modify each individual contour.

Let us know in the comments if you find any bugs or have suggestions for improvements. We would also love to know if anyone finds this tool useful for anything.

The post More fun with contours appeared first on Google Earth Blog.

Comments Off :, more...

Drawing contours with altitude data

by Timothy Whitehead on Aug.12, 2016, under 3D Models, Argentina, Australia, Brazil, California, Denmark, England, Germany, Google Earth News, Google Earth Tips, Google Sky, Google maps, Hawaii, Indonesia, Ireland, Italy, Japan, Kenya, Mexico, Natural Landmarks, Netherlands, Sightseeing, Street Views, USA

Thank you to GEB reader ‘DJ’ for suggesting this idea in the comments of our post on simulating lakes. It turns out that the algorithm for drawing contours given a regular array of altitude data is actually very simple. We used the algorithm known as ‘Marching Squares’ as described on Wikipedia. For this first attempt we are not going to bother with some of the extras, such as smoothing the final result, or dealing with saddle points.

The main difficulty is getting hold of altitude data. Google offers the Google Maps Elevation API, but it has significant restrictions, including usage limits and most important, rules about what you may do with the data, especially this line:

The Google Maps Elevation API may only be used in conjunction with displaying results on a Google map. It is prohibited to use Google Maps Elevation API data without displaying a Google map.”

If we understand that correctly as well as other restrictions regarding not storing the results, then we are not allowed to use the API to create KML files for use in Google Earth.

We had a look around for other elevation API’s but most of them have similar restrictions, i.e., you can only use them with the providers maps. There are a few that might be less restrictive, such as the ones provided by the USGS and Mapzen, but we will need to investigate them further to double check the permissions as well as how to access the data. There may be others out there. If any of our readers knows of a no-restrictions elevation API, please let us know in the comments.

For now, we have decided to run some tests with the Google Maps API and try to comply with the restrictions.

To use it, start by drawing a polygon in Google Earth, outlining the approximate area you are interested in. Save the polygon as a KML file and select it below. Choose an altitude (in metres) at which you want to draw a contour. Click the ‘Draw contour’ button.
It takes about a minute because of restrictions imposed by the Elevation API on the number of queries you are allowed to make in a given time. For this reason we have used a fairly coarse grid of 100 x 100 points.

KML polygon of the area of interest:

Altitude: m


 

 

 
 

The final result should be a black contour shown on the Google Map above. As an example, we tried the lake from our post on simulating lakes:


A contour outlining the proposed Batoka Gorge lake

The post Drawing contours with altitude data appeared first on Google Earth Blog.

Comments Off :, , , more...

Looking for something?

Use the form below to search the site:

Still not finding what you're looking for? Drop a comment on a post or contact us so we can take care of it!

Visit our friends!

A few highly recommended friends...