1

I am trying to reproject the coordinate system of a shapefile.

I know I can do it in the OSGEO4W window as ogr2ogr -s_srs EPSG:27700 -t_srs EPSG:3857 C:/test/input.shp C:/test/output.tif

However, I want to be able to do this in Python. I found this documentation but can't figure out how to achieve what I want

https://pcjericks.github.io/py-gdalogr-cookbook/vector_layers.html#create-a-new-shapefile-and-add-data

1
  • 1
    You are using output.tif instead of output.shp so it's not clear if you want to transform a shp to tiff or just reproject a shapefile, or both. Please clarify your question. Also if GDAL python bindings ir the only library you are allowed to use or other python libraries can be used. Commented Jul 9, 2022 at 11:36

1 Answer 1

1

I'm not sure I understand what you want to do: transform the epsg or convert the file shp to tif or both?

for changing the projection of a shape, I use

ogr2ogr -f "ESRI Shapefile" two.shp one.shp -s_srs EPSG:2154 -t_srs EPSG:3857 -lco ENCODING=UTF-8

if you want to rasterize, it seems to me that it is necessary to use gdal_rasterize...

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.