Skip to content

Instantly share code, notes, and snippets.

@ceteri
Created May 31, 2020
Embed
What would you like to do?
Geo 2
wget https://www2.census.gov/geo/tiger/GENZ2018/shp/cb_2018_us_state_20m.zip
mkdir maps
cd maps
unzip ../cb_2018_us_state_20m.zip
@elhamdaha

This comment has been minimized.

Copy link

@elhamdaha elhamdaha commented Jul 21, 2021

Hi- How can I get via python?

@ceteri

This comment has been minimized.

Copy link
Owner Author

@ceteri ceteri commented Jul 21, 2021

Here's an equivalent in Python:

import io
import requests 
import zipfile

url = "https://www2.census.gov/geo/tiger/GENZ2018/shp/cb_2018_us_state_20m.zip"

r = requests.get(url, stream=True)
z = zipfile.ZipFile(io.BytesIO(r.content))
z.extractall("maps")
@elhamdaha

This comment has been minimized.

Copy link

@elhamdaha elhamdaha commented Jul 22, 2021

Thank you for your response!

@elhamdaha

This comment has been minimized.

Copy link

@elhamdaha elhamdaha commented Jul 22, 2021

What if I don't save the zip code? I want to call the geo and then after preparing some queries, save a new database which includes geometry (longitude/latitude).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment