WEMAPPERS PLATFORM
Welcome, please log-in to participate in this (your) platform, by logging in you agree to abide by the rules of this forum. Until you make your FIRST Login and post.
WEMAPPERS PLATFORM
Would you like to react to this message? Create an account in a few clicks or log in to continue.
WEMAPPERS PLATFORM

WE ARE FOCUSING TO BE THE BEST SOURCE OF GEOSPATIAL KNOWLEDGE IN THE GLOBE

Who is online?
In total there are 4 users online :: 0 Registered, 0 Hidden and 4 Guests

None

Most users ever online was 117 on Sat Apr 20, 2024 9:17 pm
Discord Server
Statistics
We have 256 registered users
The newest registered user is AwezGeo

Our users have posted a total of 153 messages in 55 subjects
Top posting users this week
No user

Latest topics
» Application of remote sensing
Mapping geodata with Geopandas and Matplotlib EmptyThu Aug 04, 2022 5:16 pm by Admin

» GOOD MAP MAKING TIPS TIP1
Mapping geodata with Geopandas and Matplotlib EmptyFri Jul 15, 2022 8:09 pm by CarolinaLiki

» Web mapping programming Language
Mapping geodata with Geopandas and Matplotlib EmptySat Nov 13, 2021 12:47 pm by Afro Teop

» WHY LIDAR REMOTE SENSING IS SO EXPENSIVE? IF YOU HAVE AN ANSWER PLEASE DROP DOWN,,
Mapping geodata with Geopandas and Matplotlib EmptyMon Nov 01, 2021 11:36 am by Tumaini apolinary

» GIS analysis question
Mapping geodata with Geopandas and Matplotlib EmptyWed Jun 30, 2021 11:56 am by Geoffrey venust

» We successful performed the second geotalk
Mapping geodata with Geopandas and Matplotlib EmptyThu Jun 24, 2021 3:25 pm by Admin

» GIS DATA ANALYSIS
Mapping geodata with Geopandas and Matplotlib EmptyWed Jun 23, 2021 12:59 pm by Admin

» How Geospatial Technologies Are Being Used to Study Light Pollution
Mapping geodata with Geopandas and Matplotlib EmptyWed Jun 23, 2021 12:25 pm by Afro Teop

» DODOMA ORPHANAGE MAP
Mapping geodata with Geopandas and Matplotlib EmptyWed Jun 23, 2021 11:47 am by Afro Teop


You are not connected. Please login or register

Mapping geodata with Geopandas and Matplotlib

3 posters

Go down  Message [Page 1 of 1]

Afro Teop



Mapping geodata with Geopandas and Matplotlib

For now your are familiar with GIS python libraries.In this chapter we shall cover mapping geospatial data specifically Esri shapefile.I will be using Kenya Counties shapefile. To tackle this test you need to have installed python and you have pip installed geopandas and matplotlib but if you have anaconda environment the better.

in this steps i used Anaconda


Libraries importation


# import the needed libraries

  • import geopandas as gpd
    from matplotlib import pyplot as plt
    %matplotlib inline


Loading our data

  • # Loading our county shapefile data

    countys=gpd.read_file("county.shp")

    # we assign our county.shp data countys variable

    # we request geopandas to read our shapefile county


Examine the data

  • # we want to examine our shapefile data
    countys.head()




we are able to display only the first five items . if we want to dispaly all are a specified number of item we place n value in the head bracket e.g countys.head(46). also through this code we have displayed the properties of our data

  • # coordinate reference system
    countys.crs


  • # display columns
    countys.columns


  • # display length of columns
    len(countys)


Plotting

# plotting our counties

  • countys.plot(cmap="rainbow",figsize=(10,10))
    # to add more eg countys.plot(cmap="rainbow",figsize=(10,10))
    # cmap=rainbow assigns the map different rainbow colors also try a different color
    # try jet color
    # figsize makes the map to be 10 by 10




  • # we want to plot unit perimeter

    countys.plot(column="UNIT_PERIM",figsize=(10,10),legend=True)
    # if you want to plot the data with specific target add column with the name of the column




  • # importing towns and plotting
    town=gpd.read_file("kenya_towns.shp")
    town.plot(facecolor="black",figsize=(10,20))


  • # display both towns and counties
    fig,ax=plt.subplots(1,figsize=(10,20))
    countys.plot(ax=ax,cmap="jet",column="CODE")
    town.plot(ax=ax,facecolor="black")


Clip and intersecting


  • # dispaly single county from our data
    nairobi=countys[countys.COUNTY_NAM=="Nairobi"]
    nairobi.plot(figsize=(10,20),facecolor="none",edgecolor='black')


  • # we select Kasarani town in Nairobi and plot it
    home=town[town.TOWN_NAME=="Kasarani"]
    home.plot(facecolor="black")


  • # intersecting our Kasarani town with nairobi county
    fig,ax=plt.subplots(1,figsize=(10,20))
    home.plot(ax=ax,facecolor="black")
    nairobi.plot(ax=ax,facecolor="none",edgecolor='black')


I have attached the codes and the data feel free to use them
The End
Thank you for your time

Admin, Afro Teop and Frank Justin like this post

Afro Teop



am trying to load the codes and geodata but the zip file seems to be big,incase you need it just say and i might send through email of github account

Admin, Afro Teop and Frank Justin like this post

Admin

Admin
Admin

raphaelmr47@gmail.com

Admin and Frank Justin like this post

https://wemapper.africamotion.net

Afro Teop



check your email

Admin, Afro Teop and Frank Justin like this post

Frank Justin



This one is the simplest and clearly

Admin and Afro Teop like this post

Afro Teop



thanks a lot Frank

Admin likes this post

Sponsored content



Back to top  Message [Page 1 of 1]

Permissions in this forum:
You cannot reply to topics in this forum