Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FEATURE] Adjustment to ShapefileReader #559

Closed
jbellander opened this issue Apr 22, 2023 · 4 comments · Fixed by #570
Closed

[FEATURE] Adjustment to ShapefileReader #559

jbellander opened this issue Apr 22, 2023 · 4 comments · Fixed by #570
Labels
waiting waiting for more information before proceeding

Comments

@jbellander
Copy link

Is your feature request related to a problem? Please describe.
I'm using the shape file linked below. But the reader as it is now does not accept the file as ShapefileReader currently is implemented.

https://geodata.naturvardsverket.se/nedladdning/friluftsliv/Anordningar_shp.zip

Just as FYI that shape originates from Sweden's Environmental Protection Agencys open data.

Describe the solution you'd like
ShapefileReader:56 changed from transformToLatLon = CRS.findMathTransform(src, dest); to transformToLatLon = CRS.findMathTransform(src, dest, true); solves the issue. However not everyone will want to have it this so and option is probably needed.

Describe alternatives you've considered
n/a

Additional context
n/a

@msbarry
Copy link
Contributor

msbarry commented Apr 24, 2023

Hello @jbellander ! I tried opening that shapefile in planetiler and I get an error Bad reference system ... Bursa wolf parameters required - Are you passing in an explicit projection string?

Looks like the full coordinate reference system specification is:

PROJCS["SWEREF99_TM", 
  GEOGCS["GCS_SWEREF99", 
    DATUM["D_SWEREF99", 
      SPHEROID["GRS_1980", 6378137.0, 298.257222101]], 
    PRIMEM["Greenwich", 0.0], 
    UNIT["degree", 0.017453292519943295], 
    AXIS["Longitude", EAST], 
    AXIS["Latitude", NORTH]], 
  PROJECTION["Transverse_Mercator"], 
  PARAMETER["central_meridian", 15.0], 
  PARAMETER["latitude_of_origin", 0.0], 
  PARAMETER["scale_factor", 0.9996], 
  PARAMETER["false_easting", 500000.0], 
  PARAMETER["false_northing", 0.0], 
  UNIT["m", 1.0], 
  AXIS["x", EAST], 
  AXIS["y", NORTH]]

@msbarry msbarry added the waiting waiting for more information before proceeding label Apr 24, 2023
@jbellander
Copy link
Author

jbellander commented Apr 24, 2023

I should be honest to say that I'm on very deep water when it comes this topic. I got the same error as you. But setting lenient to true makes it work. I understand based on the article below, is that it will not make it 100% correct but good enough for display. (Which is good enough for me).

https://docs.geotools.org/stable/userguide/faq.html#q-bursa-wolf-parameters-required

Edit: Missed the link..

@msbarry
Copy link
Contributor

msbarry commented Apr 27, 2023

Ahh I was getting mixed up with CRS.decode(projection, longitudeFirst);

I'd like to move the sources to accept individual arguments like source.shp?lenient=true&projection=EPSG:3857 but that's not quite supported yet.

What do you think in the meantime what if we log a warning in this case and retry with lenient=true? So at least it will accept the input but let you know there might be issues?

Do you have a minimal shapefile that reproduces this case that I could include in the repo as a test case?

@jbellander
Copy link
Author

I understand. But doing it as a fallback with a warning would be a simple solution that would work fine for my purposes. Nice!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
waiting waiting for more information before proceeding
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants