crackernutter / EsriRESTScraper

A Python class that scrapes ESRI Rest Endpoints and exports data to a geodatabase
MIT License
48 stars 20 forks source link

How to run the code? #1

Closed Tang79 closed 8 years ago

Tang79 commented 9 years ago

Hi,

I may be missing something, but how do I run this code? Where do I enter my rest endpoint and the output location? Is there an option to run it as a tool in ArcCatalog?

Thanks for your work! I look forward to trying it out.

crackernutter commented 9 years ago

The instructions should be in the readme using an earthquakes example (read it for more details). But in short:

import RestCacheClass, arcpy earthquakesScraper = RestCacheClass.RestCache("http://rmgsc.cr.usgs.gov/ArcGIS/rest/services/nhss_haz/MapServer/3") earthquakesData = earthquakesScraper.createFeatureClass(r'C:\Geodata\earthquakes.gdb', 'earthquakes') earthquakesScraper.updateFeatureClass(earthquakesData, ["magnitude > 4"]).

Hope that helps!!!

Tang79 commented 9 years ago

I have never used a pyc file. Does this code occur in this file? Or do I need to add it to the .py file or create a new .py file? My apologies for my novice understanding.

Your Read Me says: "This class is instantiated with the Esri REST Endpoint of a feature layer inside a map service. For secured map services, you can include an optional token when instantiating the class.
e.g.

import RestCacheClass
earthquakesScraper = RestCacheClass.RestCache("http://rmgsc.cr.usgs.gov/ArcGIS/rest/services/nhss_haz/MapServer/3")
```  "

Can you elaborate in elementary terms? Thanks!
crackernutter commented 9 years ago

So you don't need ot use the pyc file - that's just created when the .py file is interpreted. You have to copy the .py file into your site-packages folder in your python directory so you in "import" it in your code. I believe the directory is C:\Python27\Arcgisinstallationversion\lib\site-packages, or something like that. A google search should help you find the exact location of the site-packages directory. Once the .py file is there, you can test in a python terminal to see if import RestCacheClass returns an error. If it doesn't, then it's working and you can run code using that library. Hope that helps!