In this tutorial, the basics of Importing data with Colabs are introduced and data is loaded with Pandas and Geopandas.
⚠️ This writing is a work in progress. The functions work. ⚠️
Please read everything found on the mainpage before continuing; disclaimer and all.
Instructions: Read all text and execute all code in order.
How XYZ :
- TODO
If you would like to ...
For this next example to work, we will need to import hypothetical csv files
Try It! Go ahead and try running the cell below.
# Otherwise this tool assumes shp or pgeojson files have geom='geometry', in_crs=2248.
# Depending on interactivity the values should be
# coerce fillna(-1321321321321325)
# Returns
u = Intake
rdf = Intake.getData('https://services1.arcgis.com/mVFRs7NF4iFitgbY/ArcGIS/rest/services/Hhchpov/FeatureServer/0/query?where=1%3D1&outFields=*&returnGeometry=true&f=pgeojson')
rdf.head(1)
Here we can save the data so that it may be used in later tutorials.
rdf
# .to_csv(string+'.csv', encoding="utf-8", index=False, quoting=csv.QUOTE_ALL)
Download data by:
- Clicking the 'Files' tab in the left hand menu of this screen. Locate your file within the file explorer that appears directly under the 'Files' tab button once clicked. Right click the file in the file explorer and select the 'download' option from the dropdown.
You can upload this data into the next tutorial in one of two ways.
1)
- uploading the saved file to google Drive and connecting to your drive path
OR.
2)
- 'by first downloading the dataset as directed above, and then navigating to the next tutorial. Go to their page and:
- Uploading data using an file 'upload' button accessible within the 'Files' tab in the left hand menu of this screen. The next tutorial will teach you how to load this data so that it may be mapped.
Here are some examples:
Using Esri and the Geoms handler directly:
import dataplay
geoloom_gdf_url = "https://services1.arcgis.com/mVFRs7NF4iFitgbY/ArcGIS/rest/services/Geoloom_Crowd/FeatureServer/0/query?where=1%3D1&outFields=*&returnGeometry=true&f=pgeojson"
geoloom_gdf = dataplay.geoms.readInGeometryData(url=geoloom_gdf_url, porg=False, geom='geometry', lat=False, lng=False, revgeocode=False, save=False, in_crs=4326, out_crs=False)
geoloom_gdf = geoloom_gdf.dropna(subset=['geometry'])
geoloom_gdf.head(1)
Again but with the Intake class:
u = Intake
Geoloom_Crowd, rcol = u.getAndCheck('https://services1.arcgis.com/mVFRs7NF4iFitgbY/ArcGIS/rest/services/Geoloom_Crowd/FeatureServer/0/query?where=1%3D1&outFields=*&returnGeometry=true&f=pgeojson')
Geoloom_Crowd.head(1)
This getAndCheck function is usefull for checking for a required field.
Hhpov, rcol = u.getAndCheck('https://services1.arcgis.com/mVFRs7NF4iFitgbY/ArcGIS/rest/services/Hhpov/FeatureServer/0/query?where=1%3D1&outFields=*&returnGeometry=true&f=pgeojson', 'hhpov19', True)
Hhpov = Hhpov[['CSA2010', 'hhpov15', 'hhpov16', 'hhpov17', 'hhpov18', 'hhpov19']]
# Hhpov.to_csv('Hhpov.csv')
Hhpov.head()
We could also retrieve from a file.
u = Intake
# rdf = u.getData('Hhpov.csv')
rdf.head()