2

I need to save my outputs, which are netcdf files or panda python tables, to shapefiles. They cannot be rasters because the software I am loading them into accepts shapefiles only.

I have googled and looked around and couldn't find some clear answers. I understood that I could call GDAL from python, and I am digging into GDAL. I know I have to reclassify the netcdf files before saving it to shapefiles. This question is not about which best shapefile is representative of a netcdf (countour, lines etc) but what is the correct script/command to use in GDAL/python to do something like:

convert netcdf_data.nc to shapefile_data.shp

I could use some more specific input.

  • 1
    What are the data, really? If you have tables or NetCDF, you're fundamentally not dealing with vector data (like shapefiles). Providing some more context about where the data came from and why you're trying to make a shapefile, might help to provide guidance. – BradHards Nov 29 '15 at 10:34
  • If your outputs are continuous values, like a grid of heights, then the best you can probably do is create a shapefile of contour lines. If your outputs are discrete values, like a grid of land use types, then you can convert to polygon shapefiles where each polygon goes round all the urban or rural grid cells. In extremis you could create a shapefile of polygons where each polygon is a square that goes round your grid cells. But without knowing why you need to save as shapefiles (and it sounds like you don't) it might be best not to at all... – Spacedman Nov 29 '15 at 16:02
  • Thanks a lot for your comments - I realize I have been too vague. My data will be maps with continuous values that can be though made discrete (transformed in classes for example). I need to save a shapefile because I need to load it on a visualization platform that does not accept netcdf or rasters but only shapefiles. So this question is more about the GDAL/python commands to use than how to go to correctly preserve the info from a netcdf to a shapefile. For that I will have to look at my outputs. But all your inputs were very helpful indeed. – claude Nov 30 '15 at 13:52
  • Have you looked at gdal.Polygonize in the python gdal wrappers? – Spacedman Nov 30 '15 at 14:13

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.