Mapping by Geopandas in Colab

แชร์
ฝัง
  • เผยแพร่เมื่อ 17 ธ.ค. 2024

ความคิดเห็น • 7

  • @mikeholad
    @mikeholad 2 ปีที่แล้ว +1

    I love your teaching.
    How do I create a city map or state map instead of country map on google colab

    • @REDBRIChk
      @REDBRIChk  2 ปีที่แล้ว

      thank you for your support. here shows an example of mapping NYC by geopandas: geopandas.org/en/stable/gallery/plotting_basemap_background.html

    • @mikeholad
      @mikeholad 2 ปีที่แล้ว

      @@REDBRIChk thanks for this but I am unable to replicate it to Ekiti State map showing 16 local government / Nigeria.
      Please can you help me out

  • @jessiekinvisiblesoci
    @jessiekinvisiblesoci 3 ปีที่แล้ว

    This tutorial in very interesting for me as I could try using Python to plot a map. Anyway, I would like to figure out the following:
    For the last routine about plot a country map, I have tried to plot a country map for the United States as the following coding:
    fig, ax_us = plt.subplots(figsize=(8,6))
    countries = gpd.read_file(gpd.datasets.get_path("naturalearth_lowres"))
    countries[countries["name"] == "United States"].plot(cmap='Greens_r', ax=ax_us)
    plt.show()
    However, there is the same error shown as follows:
    /usr/local/lib/python3.7/dist-packages/geopandas/plotting.py:681: UserWarning: The GeoDataFrame you are attempting to plot is empty. Nothing has been displayed.
    UserWarning,
    I would like to wonder what reason for plotting a country map for the US unavailable.
    thanks.

    • @REDBRIChk
      @REDBRIChk  3 ปีที่แล้ว

      If you check the names of the countries in the database, it is United States of America

    • @jessiekinvisiblesoci
      @jessiekinvisiblesoci 3 ปีที่แล้ว

      @@REDBRIChk Thanks for your reply w/ problem solved.
      On the other hand, apart from plotting a country map, I try to plot a specified city map as the following coding:
      fig, ax_hk = plt.subplots(figsize=(8,6))
      cities = gpd.read_file(gpd.datasets.get_path("naturalearth_cities"))
      cities[cities["name"] == "Hong Kong, China"].plot(cmap='Blues_r', ax=ax_hk)
      plt.show()
      However, another warning message shown about “NameError: name 'gps' is not defined”. I would like to wonder if there is another code to plot the specified city, thanks.

    • @REDBRIChk
      @REDBRIChk  3 ปีที่แล้ว

      @@jessiekinvisiblesoci You may refer to the codes provided in the following page to gpd.read_file("a shapefile") colab.research.google.com/github/la-counts/data-adventures/blob/master/Instructable_7_How_to_Analyze_Geographic_Data_in_Shapefiles.ipynb