wavded / ogre

ogr2ogr geojson-focused web client
http://ogre.adc4gis.com
MIT License
266 stars 78 forks source link

Results differ between web, api #23

Closed bgschiller closed 10 years ago

bgschiller commented 10 years ago

I have a zipped shapefile that I'm converting to GeoJSON. The results seem to differ depending on whether I use the web interface or the REST API. Results are at https://gist.github.com/bgschiller/1359832a4e14edc8f3bf, though you'll have to click through to 'raw' in order to see the JSON.

When I use the form upload at http://ogre.adc4gis.com/, the results are in EPSG:4326. For example, the first point of the first polygon is [ -0.892238897814033, 9.491482735323443 ]. These are the results I expect, and hope for.

When I use the api, the results are not lat/lon pairs. For example, the first point of the first polygon is [ 731400.951299999840558, 1049891.9822 ], which is wildly out of range for latitude and longitude.

The zipped shapefile I'm using is available at https://www.dropbox.com/s/bx8q190y31c01tj/ogre_issue_example.zip It is in UTM, but includes the .prj file.

On the web interface, i'm only filling in the fields for File, and Target SRS. File is ogre_issue_example.zip and Target SRS is EPSG:4326.

With curl, I'm using the following line:

curl -X POST -F targetSrs=EPSG:4326 -F upload=@ogre_issue_example.zip http://ogre.adc4gis.com/convert

I also tried using the python requests library, with

r = requests.post('http://ogre.adc4gis.com/convert',
          params={
                  'targetSrs':'EPSG:4326'
                  },
          files={
                 'upload':open('ogre_issue_example.zip','rb')
                 })

The results were the same as with curl.

Any advice is much appreciated. Thank you!

wavded commented 10 years ago

Thanks for the detailed report! I was able to fix a bug in the underlying ogr2ogr module which made the results inconsistent. However, in order to get the right translation in your case, you will also need to specify the sourceSrs param:

curl -v -X POST -F sourceSrs=EPSG:32630 -F targetSrs=EPSG:4326 -F upload=@ogre_issue_example.zip http://ogre.adc4gis.com/convert
bgschiller commented 10 years ago

Great, thanks for all your work!

Regarding sourceSrs: Is it enough to include a .prj file as part of the shapefile .zip? I'm using your service as a fallback for when GIS libraries aren't installed on the host computer. It's sort of error-prone to try to detect the coordinate system from the .prj file, so I'd rather pass the whole thing along if possible.

Just checked, and the results are now consistent, but it looks like ogre is ignoring the .prj file.

wavded commented 10 years ago

You are right, ogr2ogr should really be reading the projection file.. I'll take a peak

wavded commented 10 years ago

@bgschiller this change has been made, now ogr2ogr will look for the .prj file if no sourceSrs is provided

bgschiller commented 10 years ago

Thanks so much! Passes my test case -- I'll try a couple others tomorrow morning.