mapping question using BaseMap

This is the place for queries that don't fit in any of the other categories.

mapping question using BaseMap

Postby kodie425 » Wed Sep 28, 2016 9:54 pm

Hi there // I am learning python and mapping using longitude/latitide.. I have a CSV file with store_type (full line, discount), latitude, longitude.

It displays the stores fine based on lati/long currently, but I would like to apply a different color and shape based on column 0 (store type) inside stores.

My CSV file has columns 0,1,2,3 ( but I am only using columns 0 store_type, 2 latitide, 3 longitude ).

If column 0 has F, D (F - Full Line Store, D - Discount Store), how can I tell it to display a different color and shape based on column 0 ?

:?

Code: Select all
import numpy as np
import matplotlib.pyplot as plt
from mpl_toolkits.basemap import Basemap

# store data
stores = np.genfromtxt("stores_type.csv",
                         delimiter=',',
                         dtype=[('mystring','S5'),('lat', np.float32), ('long', np.float32)],
                         usecols=(0, 2, 3))

fig = plt.figure(figsize=(24,12))

# Longitute East ~ West position (Horizontal)
# Latitute  North ~ South positions (Vertical)

themap = Basemap(llcrnrlon=-119,
                 llcrnrlat=22,
                 urcrnrlon=-64,
                 urcrnrlat=49,
                 projection='lcc',
                 lat_1=33,
                 lat_2=45,
                 lon_0=-95)
           
# themap.drawcoastlines()
themap.drawcountries()
themap.drawstates()
themap.fillcontinents(color = 'gainsboro')
themap.drawmapboundary(fill_color='steelblue')

x, y = themap(stores['long'], stores['lat'])

themap.plot(x, y,
            'o',                    # marker shape
            color='Indigo',         # marker colour
            markersize=8            # marker size
            )

plt.show()
kodie425
 
Posts: 31
Joined: Sun Oct 18, 2015 1:43 am

Return to General Coding Help

Who is online

Users browsing this forum: Yahoo [Bot] and 12 guests