0

Is there a best practice for importing a polygon from CSV to SQL?

I have attempted to use the SQL Import and Export wizard to load it in as varchar(max) and then convert using geography::Parse(column) as well as Geography::STGeomFromText(column,CRS) but in both cases it failed with an error that 'Latitude values must be between -90 and 90 degrees.'

For more context, the data flow so far as been from shapefile to geodataframe using geopandas, then converted to df using pandas and sent to '.csv' using pandas

  • What coordinate system is your polygon data in? If not in LAT/LON (WGS84), then the geography column won't work. If you have data in another coordinate system, you should use the geometry type. – DPSSpatial Jun 12 at 17:00
  • Also, if you have QGIS, take a look at this script - it works pretty well for us when loading a shapefile to mssql server github.com/dpsspatial/Installation-Instructions/blob/master/… – DPSSpatial Jun 12 at 17:39
  • Thank you so much for your answers. I'm seeing now the start of my problem. I believe the CRS used is 3857 if I am following you correctly, or WGS 84/Pseudo-Mercator... the shame is that as little as I know so far, the one thing I had been consistently doing is switching to EPSG:4326 (WSG84) and somehow this got set to its default – Raymond Johnson Jun 12 at 17:49
  • The GEOGRAPHY data type won't allow for SRID:3857, but you can load that into GEOMETRY data type... – DPSSpatial Jun 12 at 18:10
  • That I did! And I thought I was set, but when comparing my latitude and longitude in my geometric polygon. . .and, unless I'm mistaken, that told me I shouldn't have. . . and I don't imagine there's reprojection options for latitude, longitude to x,y in sql without losing precision, is there? – Raymond Johnson Jun 12 at 18:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.