6

I've created a custom map in QGIS with a few shapefiles. I'm using leaflet.js to render the map and the shapefile points and everything lines up correctly. The CRS is set to 4326.

When I export the shapefiles as geojson from QGIS, the coordinates are huge and look something like this: 9949941.925330460071564, -12405330.17722519300878

Leaflet is expecting coordinates that look like this: 82.9687,63.2336

Anyone have any insight into resolving this problem?

8
  • Quick clarification, I want to export the shapefiles as geojson to zoom to specific coordinates on the prerendered map.
    – Roy Kolak
    Commented May 17, 2013 at 17:00
  • 1
    Looks like your original shapefiles are in projection that is in metres/feet need to reproject into WGS84 then your will get the expected decimal degrees.
    – Mapperz
    Commented May 17, 2013 at 17:00
  • When I right click on a shapefile > Set Layer CRS.. it's currently set to 'WGS 84' and 'EPSG:4326'. Is that what you mean?
    – Roy Kolak
    Commented May 17, 2013 at 17:06
  • 1
    That is what the layer is set to, but the data is obviously ot EPSG:4326. Do you have a .prj file for your shapefile? You can look into it with any text editor.
    – AndreJ
    Commented May 17, 2013 at 17:25
  • 1
    Ok, thats correct. But what do you get if you rightclick on the layer ->properties, Metadata tab? The extent of the layer should be within +-90/180.
    – AndreJ
    Commented May 17, 2013 at 17:37

1 Answer 1

15

Try to change the layer CRS with Rightclick ->Set Layer CRS to EPSG:3857. To verify that your data is in the correct place you can load the openlayers plugin with Google or Openstreetmap background.

For Geojson export, the target CRS must be EPSG:4326. You have to set that manually when using Rightclick->Save As....

2
  • 1
    Yes! You have saved the day.
    – Roy Kolak
    Commented May 17, 2013 at 18:28
  • and how to export a geojson file with lat and long coordinates for polygon shapefile? TY Commented Dec 7, 2022 at 12:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.