I'm script challenged and trying to repair a shapefile with a missing .shx. This tool sounds ideal: https://code.google.com/p/pyshp/, but the four step instructions are not enough. Can someone give me a quick walk through how you would run this tool.
Asked
Active
Viewed 436 times
2
-
You need to paste the file in your Python folder. For me, I want it in my ArcGIS installation of Python so I would paste it in the folder C:\Python27\ArcGIS10.1. Then you can import it from the command prompt. – Martin Nov 05 '13 at 14:32
-
Great, it's showing up in arcmap when i type import shapefile in the python screen (i'm seeing the script description on the right). How do I pass the shapefile location to it? – gorddev Nov 05 '13 at 14:38
-
See my answer below. – Martin Nov 05 '13 at 15:20
-
You may also find the following question to provide helpful alternatives to fixing your core issue: Corrupt shapefile. How to fix – RyanKDalton Nov 05 '13 at 18:50
1 Answers
3
You need to paste the file in your Python installation folder. For me, I want it in my ArcGIS installation of Python so I would paste it in the folder C:\Python27\ArcGIS10.1. Then you can import it from the command prompt with
import shapefile
To set the directory, type:
import arcpy
from arcpy import env
env.workspace = r"C:/.../folder with shapefiles"
After that you are all set to use the function, try some of the examples at the bottom of the page you linked to in your question. It also links to http://geospatialpython.com/, which has got more examples and use cases.
Martin
- 4,928
- 10
- 40
- 57