crackernutter / EsriRESTScraper

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

Need example script for configuration #6

Closed danielrogers1969 closed 7 years ago

danielrogers1969 commented 7 years ago

I'm really new to Python. Could you provide an example of configuration of this script? Where the rest service goes, output geodatabase and feature class, etc?.

Thanks,

Daniel

crackernutter commented 7 years ago

The examples are in the readme, so you should be able to copy it from there

For example, for earthquakes:

import RestCacheClass earthquakesScraper = RestCacheClass.RestCache("http://igems.doi.gov/arcgis/rest/services/igems_haz/MapServer/3") earthquakesData = earthquakesScraper.createFeatureClass(r'C:\Geodata\earthquakes.gdb', 'earthquakes') earthquakesScraper.updateFeatureClass(earthquakesData, ["magnitude > 4"])

That's really it: of course you need a local geodatabase (*.gdb) or enterprise geodatabase so need ArcMap or ArcGIS Pro, and you need a REST Endpoint to scrape. There are plenty of public REST endpoints available on various goverment websites. The one in my example is from DOI and has earthquake data.

Also, you need to install ijson now as a dependency (download it and put it in your site-packages folder. Also place the RestCacheClass.py file in your site-packages folder.
The site-packages folder is in your Python installation directory inside the Lib folder for Python 2.x installations. Hope this helps!

danielrogers1969 commented 7 years ago

So does the rest services url and output locations go in the RestCacheClass.py file, because I can't find placeholders that resemble your configuration example?

Thanks,

Daniel

crackernutter commented 7 years ago

No, so this is a class that you import to another script. You shouldn't need to modify anything in the RestCacheClass file. Just put it in your site-packages folder in your Python installation and forget about it. Then, make a new Python script and import it (use the line import RestCacheClass - because that is the name of the file). Write your specific code for the class in your new script, using the example I have up there.

So your new script, should just have the following for example. You import the RestCacheClass in the first line and make calls to its methods in the other lines...

import RestCacheClass 
earthquakesScraper = RestCacheClass.RestCache("http://igems.doi.gov/arcgis/rest/services/igems_haz/MapServer/3") 
earthquakesData = earthquakesScraper.createFeatureClass(r'C:\Geodata\earthquakes.gdb', 'earthquakes') 
earthquakesScraper.updateFeatureClass(earthquakesData, ["magnitude > 4"])
danielrogers1969 commented 7 years ago

Got it, thanks!

Daniel

On Fri, Apr 7, 2017 at 11:05 AM, Jay Gregory notifications@github.com wrote:

No, so this is a class that you import to another script. You shouldn't need to modify anything in the RestCacheClass file. Just put it in your site-packages folder in your Python installation and forget about it. Then, make a new Python script and import it (use the line import RestCacheClass

  • because that is the name of the file). Write your specific code for the class in your new script, using the example I have up there.

So your new script, should just have the following for example. You import the RestCacheClass in the first line and make calls to its methods in the other lines...

import RestCacheClass earthquakesScraper = RestCacheClass.RestCache("http://igems.doi.gov/arcgis/rest/services/igems_haz/MapServer/3") earthquakesData = earthquakesScraper.createFeatureClass(r'C:\Geodata\earthquakes.gdb', 'earthquakes') earthquakesScraper.updateFeatureClass(earthquakesData, ["magnitude > 4"])

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/crackernutter/EsriRESTScraper/issues/6#issuecomment-292578539, or mute the thread https://github.com/notifications/unsubscribe-auth/AZuWESavoCyLJr0wdY2F62zPjoD-3jibks5rtl7ggaJpZM4M15JL .