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",
                         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,
# themap.drawcoastlines()
themap.fillcontinents(color = 'gainsboro')

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

themap.plot(x, y,
            'o',                    # marker shape
            color='Indigo',         # marker colour
            markersize=8            # marker size
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 9 guests