0

I have a Powershell script that loops through a database and outputs the spatial tables into another database in GDA2020 datum. I see one particular table is outputting but is empty. This table should have over 330000 rows. Is there a limit of rows OGR can handle or is there something I can add to the script to handle this, or could it be due to this table having multiple geometry types. Here is the script in OGR to make it clearer.

ogr2ogr -s_srs "+proj=utm +zone=55 +south +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs +wktext +nadgrids=C:\Program Files\MapManager35\ProjLib\GDA94_GDA2020_conformal.gsb" -t_srs "+proj=utm +zone=55 +south +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs +wktext" -f "MSSQLSPATIAL" "MSSQL:driver={SQL Server Native Client 11.0};Server=blahblah;Database=DestinationTable;Trusted_Connection=Yes" "MSSQL:driver={SQL Server Native Client 11.0};Server=blahblah;Tables=dbo.SourceTable;Database=blahblah;Trusted_Connection=Yes" -nln outputtable
6
  • what sort of database? does ogrinfo work for that table? what does it show?
    – Ian Turton
    Commented Jul 6, 2022 at 8:14
  • Hi Ian. It's SQL Spatial to SQL Spatial. It contains all of the Council's asset data which is why it is so large. I tested this with ogrinfo and the first few features have corrupt data, which is probably why it doesn't go any further. I recall this happening before on another script. The error is 'Error 1: GetNextRawFeatures(): Corrupt data'. Could this be due to badly drawn polygons that self intersect?
    – Josh
    Commented Jul 6, 2022 at 22:18
  • Not much that can be done with a corrupt database except restore from a good backup
    – Ian Turton
    Commented Jul 7, 2022 at 7:48
  • There are quite a few invalid geometries, where geometries self intersect. Apart from manually going through and fixing every single geometry is there an OGR command that can validate SQL geometries? I tried -makevalid but it looks like that is for shp files.
    – Josh
    Commented Jul 11, 2022 at 0:55
  • The -makevalid option on ogr2ogr gdal.org/programs/ogr2ogr.html is not limited to any file format so it should work.
    – user30184
    Commented Jul 15, 2022 at 19:07

0

Your Answer

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

Browse other questions tagged or ask your own question.