2

I am trying to make a plot of the SPC's thunderstorm outlook using Python. I have downloaded the shapefile from this website http://www.spc.noaa.gov/products/outlook/day1otlk.html. Then I use this code to try to read the data.

    from mpl_toolkits.basemap import Basemap
    #draw basemap
    m=Basemap(projection='mill',llcrnrlat=20,urcrnrlat=50,llcrnrlon=-130,\
      urcrnrlon=-60,resolution='c')
    m.drawcoastlines()
    m.drawcountries()
    m.drawstates()
    m.drawmapboundary(fill_color='#FFFFFF')
    shp_info = m.readshapefile('..\day1otlk_20140709_2000_cat','thunder')

But then I get ValueError: Shapefile must have lat/lon vertices - it appears this one has vertices in map projection coordinates. Convert the shapefile to geographic coordinates using the shpproj utility from the shapelib tools.

I am pretty new to this but I understand I need to convert this shapefile to geographic coordinates but the error message is too vague and I have no idea how.

5
  • What software are you using? QGIS, ArcGIS, etc? And version
    – GISHuman
    Jul 10, 2014 at 15:17
  • Given the m.readshapefile and other commands, looks like Matlab.
    – Erica
    Jul 10, 2014 at 16:06
  • Right now I am only using Python. Is there another way to do it? I am not familiar with QGIS or ArcGIS
    – wolfpack
    Jul 10, 2014 at 16:09
  • The shpproj utility referred to in the error message can be downloaded here. It looks like a pretty straightforward tool (documentation), although I've never tried it and can't vouch for its usability.
    – Erica
    Jul 10, 2014 at 16:19
  • Do I run shpproj with Python or do I need something else?
    – wolfpack
    Jul 10, 2014 at 16:24

2 Answers 2

1

You can use ogr2ogr to reproject the shapefile. I would probably just write a shell script to call ogr2ogr before calling your python script, but there is a Python interface to ogr2ogr. It's explained here. (That example is how to convert gml to shapefile. Near the bottom of this page you can find an example of how to reproject, though not the python part.)

0

Looking at the shapefiles here all they contain is a field DN with numeric values. There is no X or Y coordinate. In order to plot anything spatially there needs to be a reference. In python I am not sure if you can do this. The shapefiles provided are polygons and lines which are meant to overlay a basemap or surface of America.

However, if you are using a software solution like ArcGIS you can add these shapefiles and they will project on the fly.

If I'm looking at the wrong dataset please let me know - or perhaps attach it to your post so I can be more useful.

1
  • Yes this is the right dataset. Obviously the set is updated and renamed every few hours but the idea is still the same. I was able to plot it on a US map in QGIS, but I was hoping to have something a little more automated.
    – wolfpack
    Jul 10, 2014 at 16:49

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.