[Python] Coordinates to census tract - Python

Discussão em 'Python' iniciado por Stack, Março 11, 2025.

  1. Stack

    Stack Membro Participativo

    How do I turn my coordinates into census tract? Geocoding related question.

    addresses = [ "1600 Pennsylvania Ave, Austin, TX 78701" , "3505 W Loop 250 N, Midland, TX 79707" , "1609 W Loop 820 N, Fort Worth, TX 76116" ]

    I have the addresses and ik how to get its coordinates. Im trying to get the census tract through the coordinates.

    cg = censusgeocode.CensusGeocode() this initilizes the object from import censusgeocode.

    currently this is my code

    for address in addresses:
    newLoc = geoLoc.geocode(address)
    if newLoc:
    census_tract = cg.coordinates(x=newLoc.latitude, y=newLoc.longitude)
    print(f"address: {newLoc.address}")
    print(f"latitude: {newLoc.latitude}")
    print(f"longitude: {newLoc.longitude}")
    print(f"census tract: {census_tract}")
    else:
    print("not found")
    time.sleep(1)

    Continue reading...

Compartilhe esta Página