Skip to content

Use SRTM 1 arc second elevation data - #1235

Merged
boldtrn merged 16 commits into
graphhopper:masterfrom
boldtrn:srtm30
Jan 8, 2018
Merged

boldtrn merged 16 commits into
graphhopper:masterfrom
boldtrn:srtm30

Conversation

@boldtrn

@boldtrn boldtrn commented Nov 29, 2017 •

Copy link
Copy Markdown
Member

This PR partially fixes #384.

With this PR we add the functionality to use SRTM 1 arc second data. I did a couple of tests so far it looks a lot better than the CGIAR data. It would be interesting to see it working together with #1220. Both PRs seem to change the data in the same direction, with both combined I think we would see a very smooth and nice looking elevation diagram. Also this would probably improve calculated routes a lot.

At first I wanted to use the ALOS data, but decided against it after reading more reviews about the ALOS data. In general it is considered to be one of the most detailed data sources, but it has some major flaws in some areas:

However, while analyzing the results, it has become apparent that it also contains
a widespread elevation anomaly. We conclude that this anomaly is the result of uncompensated
sensor noise and the data processing algorithm (downsampling of the higher resolution data).

On the other hand some studies found that the AW3D30 data has less errors than SRTM data.

I know that SRTM has similar issues especially with water surfaces being not perfectly even. Combining AW3D30, SRTMGL1, and GMTED, in the MultiElevationProvider is probably our best bet on the long term.

Here are a couple of comparison (I used the same as in #1220 ).

Schauinsland
GH Maps 29.46km ↗1891m ↘1515m
1220schauinsland-gh

PR 29.08km ↗1479m ↘1120m
1220schauinsland-pr

From Grabenstetten to St. Johan.

GH Maps 15.72km ↗907m ↘863m
1220johann-gh

PR 15.45km ↗642m ↘595m
1235johann-pr

Neuffen.

GH Maps 5.15km ↗613m ↘332m
1220neuffen-gh

PR 4.89km ↗393m ↘113m
1220neuffen-pr

Herrnstein
1220herrnstein-unsmoothed
1235fahrrad1pr

Bad Hindelang
1220badhindelang-unsmoothed
1235fahrrad2pr

* <p>
* TODO: In addition, NSF requires oral acknowledgment during all news media interviews.
* TODO: This is weird, we have to check if really want to use OpenTopography then, see: http://www.opentopography.org/citations
* <p>

@boldtrn boldtrn Nov 29, 2017 •

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I find this very weird. Maybe we find a different source for the SRTM data.

In addition, NSF requires oral acknowledgment during all news media interviews

These seems a bit much for just providing a download server :).

see: http://www.opentopography.org/citations

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed a bit strange.

Other question: how much larger is the full world wide data on disc. (CGIAR is 70GB)

@kannes kannes Dec 11, 2017 •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I build a GeoTIFF earlier this year for fun (from the raw tiles, no hole fixing etc!): https://hannes.enjoys.it/blog/2017/01/one-srtmgl1-geotiff-to-rule-them-all/

The result was ~90GB without overviews, ~120GB with. I used -co PREDICTOR 2 -co COMPRESS=DEFLATE -co TILED=YES which from my understanding was ideal.
https://www.datenatlas.de/geodata/public/srtmgl1/

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the details @kannes. I think the newer SRTMGL1 are already hole/void fixed with ASTER GDEM data?

See - https://lpdaac.usgs.gov/dataset_discovery/measures/measures_products_table/srtmgl1_v003:

Voids in the Version 3.0 products have been filled with ASTER Global Digital Elevation Model (GDEM) Version 2.0, the Global Multi-resolution Terrain Elevation Data 2010 (GMTED2010), and the National Elevation Dataset (NED)

@karussell karussell Jan 8, 2018 •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you think about a new section below the software for data licenses here (and explicitly mention what is used by default)?

I would add stuff we have here and also gtfs.

Maybe via a table

source license used as default included in repo
OpenStreetMap data for the road network ODBL yes yes
GTFS NRW TODO link no yes
SRTM elevation public domain no yes
CGIAR elevation allowed usage for GraphHopper no yes
SRTMGL1 elevation TODO link no no
OpenTopography mirror for SRTMGL1 TODO link no -

@karussell karussell left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

/**
* @author Robin Boldt
*/
public class SRTMGL1ProviderTest {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder: when we added a test isn't there also a file required under core/files/xy.hgt? Otherwise fresh tests won't run without internet or could be slow (?)

@boldtrn boldtrn Dec 4, 2017 •

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All elevation provider (except the SRTMProvider) tests don't actually return the height of a coordinate, they only return the name of the file they are going to download. I haven't seen that there are files for the srtm provider. Should we add files for the SRTMGL1 provider as well? (note, the files are 25mb large and per default not zipped). CGIAR files are also around 30mb. GMTED are >200mb. Not sure if it's easy to create small dummy files?

This is actually something that bothers me as well. I was thinking about adding a test, but to put @ignore at the test, so we can enable the test if we change something about the elevation provider, but don't use it most of the time. WDYT?

BTW: Our API/client tests probably fail if there is no internet as well (haven't tested that yet I think)?

@karussell karussell Dec 4, 2017 •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are files at core/files/*hgt.zip

Should we add files for the SRTMGL1 provider as well?

Ok, probably not :)

The idea with the @Ignore seems interesting and I think there is something in combination with maven for executing only a specific set of tests

BTW: Our API/client tests probably fail if there is no internet as well (haven't tested that yet I think)?

Yes, we should include an option to exclude it or just run it on travis?


@Override
public String toString() {
return "srtmgl1";

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a reason we use lower case here and upper case in the other? I would prefer having the same case for all even if this means changing the old case.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a reason we use lower case here and upper case in the other?

Oh sorry I missed that. The GMTED provider is also lowercase. I can change both. I just thought it should be the same as the config value.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes more sense if they have the config value. Would this break some tests or usage scenarios?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would this break some tests or usage scenarios?

I don't think so. I actually think the toString method is only used to do a System.out:

logger.info(this.toString() + " Elevation Provider, from: " + baseUrl + ", to: " + cacheDir + ", as: " + daType);

* <p>
* TODO: In addition, NSF requires oral acknowledgment during all news media interviews.
* TODO: This is weird, we have to check if really want to use OpenTopography then, see: http://www.opentopography.org/citations
* <p>

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed a bit strange.

Other question: how much larger is the full world wide data on disc. (CGIAR is 70GB)

@karussell karussell added this to the 0.10 milestone Dec 4, 2017
@karussell

karussell commented Dec 4, 2017 •

Copy link
Copy Markdown
Member

One minor question: did you do the screenshots without douglas peucker? (and do not hesitate to create a PR that disables douglas peucker for debug=true :))

@boldtrn

boldtrn commented Dec 4, 2017

Copy link
Copy Markdown
Member Author

One minor question: did you do the screenshots without douglas peucker?

Yes all screenshots were taken with waypoint_max_distance=0. I also added the parameter in the sample requests links above.

Other question: how much larger is the full world wide data on disc. (CGIAR is 70GB)

Good question. So every .hgt file is 25mb large. There are about 14000 files. So the overall size should be at around 340 gb. I haven't tested it though. According to this link it's 318 gb.

BTW, according to this link, ASTER GDEM is about 560gb.

@boldtrn

boldtrn commented Dec 5, 2017

Copy link
Copy Markdown
Member Author

and do not hesitate to create a PR that disables douglas peucker for debug=true :)

I thought about this a bit. I am not sure if this is wanted/expected behavior. Think about you have a request and want to inspect it, you set debug=true and suddenly you receive more points. I think this would be unexpected. WDYT?

@karussell

Copy link
Copy Markdown
Member

Think about you have a request and want to inspect it, you set debug=true and suddenly you receive more points. I think this would be unexpected.

You are probably right. And as avoiding douglas peucker is already possible we should avoid too many things on debug=true :)

@karussell

Copy link
Copy Markdown
Member

Looks like a good improvement.

Can we reduce the code in the GraphHopper class a bit and why is the RAM increase necessary? (because of the tests with tiles of 30 degree resolution?)

@boldtrn

boldtrn commented Dec 6, 2017 •

Copy link
Copy Markdown
Member Author

Oh, this would be ugly. We need to have the memory really on a very low level to detect memory issues very early.

Sorry I should have mentioned that the last commit changing the memory limit was intended to show that the tests work, but Travis timed out. As discussed earlier, I will @ignore these tests and set the memory limit back to the original value.

Can we reduce the code in the GraphHopper class a bit

Sure :).

why is the RAM increase necessary? (because of the tests with tiles of 30 degree resolution?)

Yes.

Sorry I should have mentioned that this PR wasn't considered mergeable after yesterday's commit :(.

BTW: Will commit tomorrow, sorry for the delay :(.

@karussell

Copy link
Copy Markdown
Member

Sorry I should have mentioned that this PR wasn't considered mergeable after yesterday's commit :(. > BTW: Will commit tomorrow, sorry for the delay :(

Really no problem ... all fine and please no hurry :)

@boldtrn

boldtrn commented Dec 7, 2017

Copy link
Copy Markdown
Member Author

@karussell do you remember why we read the width of the tile in the SRTM provider (see here): int width = (int) (Math.sqrt(heights.getHeader(WIDTH_BYTE_INDEX)) + 0.5); and in the CGIAR provider we just assume that the width would be the default (see here). This is one major difference between SRTM and TIFF handling that makes it complicated to extract some of the logic into a common super class.

This document describes the number of rows and colums for the SRTM files so it seems reasonalbe to me to assume that all files use the same width?

Improved FileNotFound handling for the SRTMGL1Provider
Some minor improvements
*
*
* http://www.apache.org/licenses/LICENSE-2.0
*

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just updated IntelliJ, they added formatting for Copyright Statements (I mean who hasn't been waiting for this great feature). Even if I disable formatting for copyright statements and for java doc IntelliJ still messes this up...

Before merging I could just overwrite all copyright statements that got changed by the autoformatting?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sure

@karussell

Copy link
Copy Markdown
Member

I think we read&store the width because of the different resolutions (30 vs. 90). If you click blame you see this commit: 2e60c80

@boldtrn

boldtrn commented Dec 8, 2017

Copy link
Copy Markdown
Member Author

I think we read&store the width because of the different resolutions (30 vs. 90). If you click blame you see this commit

Ah ok makes sense. Since we have two different providers for this now, we could think about reverting this and define the width before. I think this would make the code a bit nicer and we might be able to abstract more and reduce the code duplication.

I updated the PR adding some more tests that check that the borders between the HeightTiles are aligned correctly.

BTW: A very handy tool to check elevation is the elevation-service by @perliedman.

/*
* Licensed to GraphHopper GmbH under one or more contributor
* license agreements. See the NOTICE file distributed with this work for
* license agreements. See the NOTICE file distributed with this work for

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried to copy the copyright information from a different class in GraphHopper and I think that the applied formatting is actually correct and that the formatting before has been wrong, so I would keep it that way.

@boldtrn

boldtrn commented Dec 8, 2017

Copy link
Copy Markdown
Member Author

I think this PR should be good to merge now. If we want to change the width handling of the SRTM provider I could further try to further melt down the code.

Something worth checking would be also if there is a major slow down due to the getFileName method. This method uses String.format and builds Strings with '+' instead of using StringBuilder. I would assume that the jit should be able to properly optimize these methods. If there is a performance issue I would revisit this method and try to improve it's performance.

@karussell

Copy link
Copy Markdown
Member

I think this would make the code a bit nicer and we might be able to abstract more and reduce the code duplication.

Sure, let's write this down in another issue

This method uses String.format and builds Strings with '+' instead of using StringBuilder

Yes, I think it is necessary to avoid String.format in this method (but you can easily prove me wrong via comparing this for world wide import ;)). Please see CGIARProvider where I wrote that String.format makes problems (btw: I do not think that strings and pluses are a problem due to the JIT you mentioned).

@boldtrn

boldtrn commented Dec 13, 2017

Copy link
Copy Markdown
Member Author

Yes, I think it is necessary to avoid String.format in this method (but you can easily prove me wrong via comparing this for world wide import ;)).

String.format is definitely slower than using regular concatenation, so I just changed it. Even if the difference might be small, having a faster import is always better.

I think this PR should be mergeable now. Let me know if I should change anything?

@boldtrn

boldtrn commented Dec 14, 2017

Copy link
Copy Markdown
Member Author

I did a minor change here. I kept the CGIAR provider as default provider in the MultiProvider so that we don't break any existing code. Over time it might make sense to set the SRTMGL1Provider as the default provider.

public void setAutoRemoveTemporaryFiles(boolean autoRemoveTemporary) {
this.autoRemoveTemporary = autoRemoveTemporary;
}
abstract boolean outsideSupportedArea(double lat, double lon);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know this is not a setter but do we need Java code style here: isOutsideSupportedArea?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense :). I changed the method name.

@boldtrn boldtrn mentioned this pull request Jan 8, 2018
@boldtrn
boldtrn merged commit 2463090 into graphhopper:master Jan 8, 2018
@boldtrn
boldtrn deleted the srtm30 branch January 8, 2018 23:40
@boldtrn

boldtrn commented Jan 8, 2018

Copy link
Copy Markdown
Member Author

Merged this PR after updating the method name

@karussell

Copy link
Copy Markdown
Member

Thanks, will be deployed in the next days!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Use high precision elevation data

3 participants