Skip to content

Commit

Permalink
working on the map data visualization
Browse files Browse the repository at this point in the history
  • Loading branch information
nathangeology committed Oct 14, 2018
1 parent cd4f62f commit 6f47ef2
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 10 deletions.
32 changes: 27 additions & 5 deletions geoviz/src/alitair_well_location_map.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,29 @@
import altair as alt
from vega_datasets import data

import geopandas as gpd

class WellLocationMap(object):
@classmethod
def create_map_plot(cls, df):
def create_map_plot(cls, df, background):
geoframe = df.copy()
ocean_shp = gpd.read_file(background)
temp = ocean_shp[ocean_shp['NAME'] == 'North Sea']
df = df[['X', 'Y', 'wlbWellbor']]
minY = df['Y'].min()
maxY = df['Y'].max()
minX = df['X'].min()
maxX = df['X'].max()
hover = alt.selection(type='single', on='mouseover', nearest=True,
fields=['X', 'Y'])
df = alt.Chart(df).encode(
longitude=alt.Longitude('X:Q'),
latitude=alt.Latitude('Y:Q')
)
countries = alt.topo_feature(data.world_110m.url, 'countries')

base = alt.Chart(countries).mark_geoshape(
fill='#666666',
stroke='white'
stroke='white',
).properties(
width=600,
height=400
Expand All @@ -18,7 +32,15 @@ def create_map_plot(cls, df):
charts = [base.project(proj).properties(title=proj)
for proj in projections]

map_chart_data = alt.Chart(df).mark_geoshape().project('mercator')
map_chart_data = df.mark_point().encode(
color=alt.value('black'),
size=alt.value(0.5),

return map_chart_data
).project('mercator').add_selection(hover)

text = df.mark_text(dy=-5, align='right').encode(
alt.Text('wlbWellbor', type='nominal'),
opacity=alt.condition(~hover, alt.value(0), alt.value(1))
)
return charts[0] + map_chart_data + text

5 changes: 1 addition & 4 deletions geoviz/src/load_shapefile_data.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
import pandas as pd
import shapefile
from collections import defaultdict
from osgeo import ogr, osr

import geopandas as gpd

class LoadShpData(object):
Expand Down
4 changes: 3 additions & 1 deletion geoviz/tests/test_wellLocationMap.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,10 @@ class TestWellLocationMap(TestCase):
def setUp(self):
self.filename = pkg_resources.resource_filename("geoviz", "sample_data/loc_npd_ea_wells.shp")
self.test_data = LoadShpData.get_data(self.filename)
self.sea_shape_file = pkg_resources.resource_filename("geoviz", "sample_data/World_Seas_IHO_v3.shp")
# self.sea_shape = LoadShpData.get_data(self.sea_shape_file)

def test_create_map_plot(self):
chart = WellLocationMap.create_map_plot(self.test_data)
chart = WellLocationMap.create_map_plot(self.test_data, self.sea_shape_file)
chart.serve()
print('here')

0 comments on commit 6f47ef2

Please sign in to comment.