1

I currently have a heap of GDAL scripts that reproject from one SQL feature class into a new SQL feature class, but I want to convert these into Python scripts using the GDAL library, to clean up my workflows. I can't seem to find any information on updating SQL data with Python using GDAL. I can only find information on reprojection shapefiles. Can this be done?

I currently use the below

ogr2ogr -f "MSSQLSpatial" -update -append -s_srs "EPSG:4283" "MSSQL:server=blahblah;database=blahblah;trusted_connection=yes" "MSSQL:server=blahblah;database=blahblah;trusted_connection=yes" -sql "SELECT blahblah FROM blahblah_original" -t_srs "EPSG:28355" -nln "blahblah_repojected" -lco "GEOM_TYPE=geometry" -lco "GEOM_NAME=GEOMETRY_SPA" "OVERWRITE=YES"

PolyGeo
  • 65,136
  • 29
  • 109
  • 338
  • as with most questions like this the answer is yes with some work – Ian Turton Mar 07 '23 at 08:36
  • Welcome to GIS SE! We're a little different from other sites; this isn't a discussion forum but a Q&A site. Your questions should as much as possible describe not just what you want to do, but precisely what you have tried and where you are stuck trying that. Please check out our short [tour] for more about how the site works – Ian Turton Mar 07 '23 at 08:36
  • I thought as much. I have plenty of Python scripts that deal with SQL so I will see if I can incorporate some of these libraries. – Joshua J Geoghegan Mar 07 '23 at 22:11
  • Look at https://gis.stackexchange.com/questions/397023/issue-to-convert-from-postgresql-input-to-gpkg-using-python-gdal-api-function-gd (PostgreSQL case) to get the idea. The key is to use gdal.VectorTranslate to make similar calls as the one in your cli but trough native Python code. – ThomasG77 May 31 '23 at 15:36

0 Answers0