Introduction to vector data cubes#
In geospatial analysis, data cubes can be of two sorts. The first is a raster data cube, typically represented by an Xarray DataArray indexed either by x
or y
dimensions or latitude
and longitude
. The second is a vector data cube, which is an n-D array with at least one dimension indexed by a 2-D array of vector geometries (Pebesma, 2022).
The Xvec package brings support for indexing by an array of vector geometries to the Xarray ecosystem. It uses Shapely1Shapely 2 or newer is required. Shapely 1.8 or older will not work with Xvec, as the geometries are not hashable before the 2.0 release. package, allowing a seamless interface between Xvec and GeoPandas.
Let’s have a look at how that looks in practice. You need to import xarray
and xvec
to enable the .xvec
accessor on Xarray objects. For this tutorial, you will also use’ geopandas’ to read the geometries and geodatasets
to fetch the data.
import geopandas as gpd
import xarray as xr
import xvec
from geodatasets import get_path
The simplest DataArray#
The simplest vector data cube would be an array of values indexed by an array of geometries, conceptually similar to geopandas.GeoSeries
.
Open a "geoda.natregimes"
dataset that contains US counties with some demographic data and create a data cube of population counts out of the GeoDataFrame.
counties = gpd.read_file(get_path("geoda.natregimes"))
For the simplest case, use just a geometry column and a column PO60
representing the population in 1960.
pop1960 = xr.DataArray(counties.PO60, coords=[counties.geometry], dims=["county"])
pop1960
<xarray.DataArray 'PO60' (county: 3085)> array([ 4304, 3889, 17884, ..., 21583, 50164, 39260]) Coordinates: * county (county) object POLYGON ((-95.34258270263672 48.54670333862305, ...
- county: 3085
- 4304 3889 17884 25520 6914 5809 ... 46235 39085 21583 50164 39260
array([ 4304, 3889, 17884, ..., 21583, 50164, 39260])
- county(county)objectPOLYGON ((-95.34258270263672 48....
array([<POLYGON ((-95.343 48.547, -95.341 48.715, -95.094 48.717, -95.095 48.912, -...>, <POLYGON ((-118.851 47.95, -118.847 48.478, -118.869 48.479, -118.87 48.647,...>, <POLYGON ((-117.438 48.044, -117.541 48.043, -117.536 47.79, -117.607 47.798...>, ..., <POLYGON ((-76.396 37.108, -76.403 37.091, -76.434 37.089, -76.464 37.103, -...>, <POLYGON ((-77.532 38.565, -77.721 38.84, -77.707 38.877, -77.678 38.885, -7...>, <POLYGON ((-111.372 44.745, -111.368 45.35, -111.349 45.349, -111.349 45.635...>], dtype=object)
- countyPandasIndex
PandasIndex(Index([ POLYGON ((-95.34258270263672 48.54670333862305, -95.34081268310547 48.71519088745117, -95.09413146972656 48.717376708984375, -95.09468078613281 48.911773681640625, -95.13359069824219 48.89449691772461, -95.21934509277344 48.879459381103516, -95.29002380371094 48.90296173095703, -95.31393432617188 48.93208312988281, -95.30352020263672 48.94594955444336, -95.3206787109375 48.96098709106445, -95.322998046875 48.978965759277344, -95.30988311767578 48.993404388427734, -95.27642059326172 49, -95.15751647949219 49.000003814697266, -95.15162658691406 49.371734619140625, -94.8318099975586 49.330810546875, -94.68103790283203 48.87717819213867, -94.69422149658203 48.77763748168945, -94.57010650634766 48.71370315551758, -94.43043518066406 48.7108154296875, -94.43147277832031 48.368247985839844, -95.21153259277344 48.36903381347656, -95.21959686279297 48.54438018798828, -95.34258270263672 48.54670333862305)), POLYGON ((-118.85050201416016 47.94968795776367, -118.84732055664062 48.47818374633789, -118.8691177368164 48.47928237915039, -118.86991119384766 48.64735412597656, -118.83859252929688 48.64915466308594, -118.84245300292969 49, -118.19923400878906 49.000003814697266, -118.21124267578125 48.981353759765625, -118.21382904052734 48.93693542480469, -118.19969177246094 48.913475036621094, -118.20854949951172 48.87502670288086, -118.13988494873047 48.785003662109375, -118.1234359741211 48.78236389160156, -118.12683868408203 48.74259948730469, -118.11392211914062 48.7066650390625, -118.12319946289062 48.69042205810547, -118.0889663696289 48.643577575683594, -118.1212158203125 48.6160774230957, -118.12586975097656 48.5703239440918, -118.1465072631836 48.54338073730469, -118.1448745727539 48.52815628051758, -118.19438934326172 48.4820442199707, -118.2115249633789 48.452362060546875, -118.1692886352539 48.29816436767578, -118.1444320678711 48.273460388183594, -118.14723205566406 48.240234375, -118.18930053710938 48.20622253417969, -118.19364166259766 48.14763641357422, -118.24517059326172 48.11769104003906, -118.2355728149414 48.07537078857422, -118.24871826171875 48.05636215209961, -118.27955627441406 48.04364013671875, -118.36463928222656 48.04145431518555, -118.38520050048828 48.023738861083984, -118.37992858886719 47.997989654541016, -118.35428619384766 47.966453552246094, -118.3431625366211 47.885498046875, -118.36705780029297 47.83599090576172, -118.43177795410156 47.83902359008789, -118.45823669433594 47.8774299621582, -118.50589752197266 47.86955261230469, -118.52824401855469 47.87391662597656, -118.542724609375 47.9161262512207, -118.55567169189453 47.921974182128906, -118.62446594238281 47.92210388183594, -118.68145751953125 47.93524932861328, -118.72828674316406 47.89552307128906, -118.81940460205078 47.923377990722656, -118.83069610595703 47.941192626953125, -118.85050201416016 47.94968795776367)), POLYGON ((-117.43777465820312 48.044219970703125, -117.54113006591797 48.04339599609375, -117.53565216064453 47.790122985839844, -117.60706329345703 47.79811477661133, -117.62619018554688 47.82703399658203, -117.661376953125 47.844364166259766, -117.67390441894531 47.88390350341797, -117.69734954833984 47.87043380737305, -117.71048736572266 47.83951950073242, -117.72587585449219 47.830692291259766, -117.80374908447266 47.81138610839844, -117.82064056396484 47.81635665893555, -117.84178161621094 47.836944580078125, -117.86885833740234 47.84736633300781, -117.93526458740234 47.828060150146484, -117.99320220947266 47.829959869384766, -118.03108978271484 47.79883575439453, -118.07076263427734 47.79669952392578, -118.10222625732422 47.82637405395508, -118.11981964111328 47.831298828125, -118.12512969970703 47.865787506103516, -118.15782165527344 47.88578414916992, -118.21208953857422 47.940589904785156, -118.2773208618164 47.93033218383789, -118.3270492553711 47.8884162902832, -118.3431625366211 47.885498046875, -118.35428619384766 47.966453552246094, -118.37992858886719 47.997989654541016, -118.38520050048828 48.023738861083984, -118.36463928222656 48.04145431518555, -118.27955627441406 48.04364013671875, -118.24871826171875 48.05636215209961, -118.2355728149414 48.07537078857422, -118.24517059326172 48.11769104003906, -118.19364166259766 48.14763641357422, -118.18930053710938 48.20622253417969, -118.14723205566406 48.240234375, -118.1444320678711 48.273460388183594, -118.1692886352539 48.29816436767578, -118.2115249633789 48.452362060546875, -118.19438934326172 48.4820442199707, -118.1448745727539 48.52815628051758, -118.1465072631836 48.54338073730469, -118.12586975097656 48.5703239440918, -118.1212158203125 48.6160774230957, -118.0889663696289 48.643577575683594, -118.12319946289062 48.69042205810547, -118.11392211914062 48.7066650390625, -118.12683868408203 48.74259948730469, -118.1234359741211 48.78236389160156, -118.13988494873047 48.785003662109375, -118.20854949951172 48.87502670288086, -118.19969177246094 48.913475036621094, -118.21382904052734 48.93693542480469, -118.21124267578125 48.981353759765625, -118.19923400878906 49.000003814697266, -117.4375 48.999996185302734, -117.43280792236328 48.92116165161133, -117.49853515625 48.919090270996094, -117.4992904663086 48.84003829956055, -117.56493377685547 48.83840560913086, -117.56617736816406 48.74644088745117, -117.63445281982422 48.74475860595703, -117.63490295410156 48.65144729614258, -117.50534057617188 48.652896881103516, -117.49925994873047 48.13341522216797, -117.43904876708984 48.133155822753906, -117.43777465820312 48.044219970703125)), POLYGON ((-118.97096252441406 47.93927764892578, -118.97293090820312 47.95952224731445, -118.95288848876953 47.988826751708984, -118.95314025878906 48.01969909667969, -119.00265502929688 48.04802322387695, -119.02192687988281 48.102596282958984, -119.04718017578125 48.13127136230469, -119.12357330322266 48.14994812011719, -119.24658966064453 48.10607147216797, -119.31358337402344 48.10681915283203, -119.33311462402344 48.08574676513672, -119.33546447753906 48.057132720947266, -119.36140441894531 48.04563522338867, -119.4032974243164 48.045379638671875, -119.45783996582031 48.07577133178711, -119.50858306884766 48.07670974731445, -119.61320495605469 48.005191802978516, -119.63855743408203 47.997337341308594, -119.66097259521484 48.0005989074707, -119.6896743774414 48.024932861328125, -119.67440032958984 48.08053970336914, -119.72725677490234 48.08320617675781, -119.74280548095703 48.099037170410156, -119.76246643066406 48.10002899169922, -119.77201080322266 48.08600997924805, -119.80925750732422 48.08710861206055, -119.89358520507812 48.052188873291016, -119.89368438720703 48.03927993774414, -119.8696517944336 48.015350341796875, -119.88492584228516 47.979087829589844, -119.87117004394531 47.95817565917969, -120.06082916259766 47.95781326293945, -120.06687927246094 47.98579406738281, -120.09114837646484 47.99908447265625, -120.09004211425781 48.018470764160156, -120.1189956665039 48.030269622802734, -120.13697814941406 48.05291748046875, -120.22477722167969 48.09194564819336, -120.27095794677734 48.122222900390625, -120.31946563720703 48.1312255859375, -120.33628845214844 48.14235305786133, -120.34803771972656 48.160057067871094, -120.34986877441406 48.20845031738281, -120.37667083740234 48.21564483642578, -120.39342498779297 48.23784637451172, -120.45291137695312 48.25991439819336, -120.50516510009766 48.2978401184082, -120.5666275024414 48.317054748535156, -120.57020568847656 48.33265686035156, -120.5448226928711 48.352691650390625, -120.54747009277344 48.363704681396484, -120.55828094482422 48.374969482421875, -120.59261322021484 48.381473541259766, -120.62755584716797 48.398582458496094, -120.6495132446289 48.43818283081055, -120.64888000488281 48.45112609863281, -120.62786865234375 48.464603424072266, -120.6484603881836 48.47977066040039, -120.62618255615234 48.4951286315918, -120.64937591552734 48.5079231262207, -120.6458969116211 48.53064727783203, -120.65241241455078 48.537410736083984, -120.69790649414062 48.534828186035156, -120.68535614013672 48.55363845825195, -120.69154357910156 48.578426361083984, -120.71127319335938 48.58945846557617, -120.74890899658203 48.58013916015625, -120.77144622802734 48.592472076416016, -120.77459716796875 48.622886657714844, -120.76148223876953 48.64357376098633, -120.74452209472656 48.645416259765625, -120.73896026611328 48.655269622802734, -120.70797729492188 48.662559509277344, -120.70883178710938 48.67733383178711, -120.69279479980469 48.69532012939453, -120.66680908203125 48.69461441040039, -120.65744018554688 48.72213363647461, -120.66437530517578 48.73582458496094, -120.72101593017578 48.769935607910156, -120.7339096069336 48.79179000854492, -120.7298355102539 48.851104736328125, -120.76712799072266 48.89174270629883, -120.76860046386719 48.916690826416016, -120.7502212524414 48.930599212646484, -120.76007080078125 48.946529388427734, -120.78802490234375 48.955501556396484, -120.82616424560547 48.939659118652344, -120.87342071533203 48.961509704589844, -120.87460327148438 48.96980667114258, -120.85607147216797 48.980960845947266, -120.85582733154297 48.99997329711914, -118.84245300292969 49, -118.83859252929688 48.64915466308594, -118.86991119384766 48.64735412597656, -118.8691177368164 48.47928237915039, -118.84732055664062 48.47818374633789, -118.85050201416016 47.94968795776367, -118.9365005493164 47.93745803833008, -118.97096252441406 47.93927764892578)), POLYGON ((-117.4375 48.999996185302734, -117.03097534179688 49, -117.02804565429688 48.83815002441406, -117.03783416748047 48.04628372192383, -117.43777465820312 48.044219970703125, -117.43904876708984 48.133155822753906, -117.49925994873047 48.13341522216797, -117.50534057617188 48.652896881103516, -117.63490295410156 48.65144729614258, -117.63445281982422 48.74475860595703, -117.56617736816406 48.74644088745117, -117.56493377685547 48.83840560913086, -117.4992904663086 48.84003829956055, -117.49853515625 48.919090270996094, -117.43280792236328 48.92116165161133, -117.4375 48.999996185302734)), POLYGON ((-117.02804565429688 48.83815002441406, -117.03097534179688 49, -116.0625 48.999996185302734, -116.05567932128906 48.49872589111328, -116.78570556640625 48.49620819091797, -116.78662109375 48.836605072021484, -117.02804565429688 48.83815002441406)), POLYGON ((-116.05449676513672 48.20854949951172, -116.05567932128906 48.49872589111328, -116.0625 48.999996185302734, -114.72833251953125 49, -114.71520233154297 48.97959518432617, -114.68336486816406 48.96889877319336, -114.71849822998047 48.92552947998047, -114.70780181884766 48.9179573059082, -114.68729400634766 48.840858459472656, -114.72557067871094 48.822532653808594, -114.72889709472656 48.80594253540039, -114.66387939453125 48.7886962890625, -114.61430358886719 48.7430305480957, -114.65087127685547 48.73301696777344, -114.68728637695312 48.70820617675781, -114.67980194091797 48.68867874145508, -114.6885986328125 48.67172622680664, -114.66167449951172 48.66157913208008, -114.65394592285156 48.64897537231445, -114.88861846923828 48.6480827331543, -114.88729095458984 48.564002990722656, -114.8492202758789 48.56157684326172, -114.85111236572266 48.21918869018555, -115.01919555664062 48.217529296875, -115.00869750976562 48.0085563659668, -115.15058898925781 48.00590515136719, -115.14938354492188 47.97732925415039, -115.12898254394531 47.959083557128906, -115.15287017822266 47.949729919433594, -115.17498779296875 47.9550895690918, -115.1773681640625 47.91826629638672, -115.20132446289062 47.90568161010742, -115.25193786621094 47.90402603149414, -115.26435089111328 47.893585205078125, -115.28667449951172 47.89064025878906, -115.33409118652344 47.907798767089844, -115.38624572753906 47.89828109741211, -115.3969497680664 47.90162658691406, -115.41312408447266 47.92945098876953, -115.42781829833984 47.90750503540039, -115.48710632324219 47.9095458984375, -115.52169036865234 47.90070343017578, -115.54246520996094 47.90645217895508, -115.55812072753906 47.93010330200195, -115.54316711425781 47.96541976928711, -115.54998016357422 47.99266815185547, -115.59925842285156 48.024044036865234, -115.6348876953125 48.06402587890625, -115.65664672851562 48.12276840209961, -115.67771911621094 48.15108871459961, -115.69581604003906 48.15955352783203, -115.68624877929688 48.197269439697266, -115.71380615234375 48.242252349853516, -115.74884033203125 48.252716064453125, -115.76717376708984 48.25103759765625, -115.80658721923828 48.208953857421875, -115.87049102783203 48.195655822753906, -115.9039535522461 48.178863525390625, -115.9500961303711 48.17230224609375, -115.9579086303711 48.149776458740234, -115.97016906738281 48.14479446411133, -116.01338958740234 48.150177001953125, -116.02333068847656 48.16407775878906, -116.01480102539062 48.19075393676758, -116.02073669433594 48.20140075683594, -116.05449676513672 48.20854949951172)), POLYGON ((-113.47271728515625 47.59763717651367, -113.63639831542969 47.60032653808594, -113.62767028808594 47.652130126953125, -113.6019287109375 47.66899490356445, -113.60262298583984 47.6943359375, -113.6074447631836 47.70504379272461, -113.6377182006836 47.70486068725586, -113.64305114746094 47.71880340576172, -113.66983795166016 47.734188079833984, -113.67061614990234 47.74525833129883, -113.65161895751953 47.761383056640625, -113.68258666992188 47.80081558227539, -113.66650390625 47.81240463256836, -113.67426300048828 47.85819625854492, -113.6657943725586 47.878726959228516, -113.72884368896484 47.91201400756836, -113.74746704101562 47.94424819946289, -113.75936889648438 47.94913864135742, -113.77124786376953 47.94111633300781, -113.80789947509766 47.977909088134766, -113.8425521850586 47.9736328125, -113.86148834228516 48.000789642333984, -113.86300659179688 48.02525329589844, -113.88099670410156 48.044559478759766, -114.02298736572266 48.04351806640625, -114.02103424072266 48.02734375, -114.05219268798828 48.025699615478516, -114.05307006835938 48.00636291503906, -114.07818603515625 48.003665924072266, -114.06419372558594 47.984474182128906, -114.04727935791016 47.98503494262695, -114.03996276855469 47.953086853027344, -114.5002212524414 47.953819274902344, -114.50009155273438 47.86951446533203, -114.48531341552734 47.86832809448242, -114.48396301269531 47.78125762939453, -114.6064682006836 47.78112030029297, -114.60806274414062 47.865882873535156, -114.98614501953125 47.864967346191406, -114.98662567138672 48.001792907714844, -115.00823211669922 48.00164031982422, -115.00869750976562 48.0085563659668, -115.01919555664062 48.217529296875, -114.85111236572266 48.21918869018555, -114.8492202758789 48.56157684326172, -114.88729095458984 48.564002990722656, -114.88861846923828 48.6480827331543, -114.65394592285156 48.64897537231445, -114.66167449951172 48.66157913208008, -114.6885986328125 48.67172622680664, -114.67980194091797 48.68867874145508, -114.68728637695312 48.70820617675781, -114.65087127685547 48.73301696777344, -114.61430358886719 48.7430305480957, -114.66387939453125 48.7886962890625, -114.72889709472656 48.80594253540039, -114.72557067871094 48.822532653808594, -114.68729400634766 48.840858459472656, -114.70780181884766 48.9179573059082, -114.71849822998047 48.92552947998047, -114.68336486816406 48.96889877319336, -114.71520233154297 48.97959518432617, -114.72833251953125 49, -114.0625 49, -114.06695556640625 48.985164642333984, -114.05577087402344 48.9599494934082, -114.02249145507812 48.95323181152344, -114.05198669433594 48.92285919189453, -114.03021240234375 48.91962432861328, -114.01795959472656 48.903175354003906, -114.01712799072266 48.891597747802734, -114.03350830078125 48.87806701660156, -114.02151489257812 48.8560791015625, -113.98932647705078 48.84197998046875, -113.99457550048828 48.81758499145508, -113.9499740600586 48.80598831176758, -113.92074584960938 48.81645202636719, -113.91020202636719 48.83656692504883, -113.8742904663086 48.82929611206055, -113.85028839111328 48.844482421875, -113.82147979736328 48.831809997558594, -113.80300903320312 48.83185577392578, -113.77190399169922 48.81079864501953, -113.78099822998047 48.779563903808594, -113.7709732055664 48.76130294799805, -113.71725463867188 48.72908401489258, -113.70914459228516 48.70069885253906, -113.71166229248047 48.69151306152344, -113.73611450195312 48.6805305480957, -113.73040008544922 48.65867614746094, -113.7479248046875 48.63597869873047, -113.75214385986328 48.60650634765625, -113.68362426757812 48.58641815185547, -113.63603973388672 48.583900451660156, -113.61024475097656 48.56895446777344, -113.55496215820312 48.570377349853516, -113.50665283203125 48.54377746582031, -113.48296356201172 48.540870666503906, -113.48306274414062 48.43927001953125, -113.46344757080078 48.424922943115234, -113.4206771850586 48.4113655090332, -113.36693572998047 48.411827087402344, -113.33970642089844 48.36448287963867, -113.38793182373047 48.32835006713867, -113.36773681640625 48.301055908203125, -113.36077880859375 48.29210662841797, -113.34195709228516 48.28884506225586, -113.34391021728516 48.278282165527344, -113.30850982666016 48.26858139038086, -113.28533935546875 48.246742248535156, -113.26030731201172 48.245609283447266, -113.23178100585938 48.2231559753418, -113.24248504638672 48.20221710205078, -113.23580932617188 48.165592193603516, -113.21051788330078 48.15798568725586, -113.18514251708984 48.163291931152344, -113.1578598022461 48.14363098144531, -113.1180419921875 48.13007354736328, -113.07853698730469 48.145111083984375, -113.06403350830078 48.138710021972656, -113.05656433105469 48.11681365966797, -113.00210571289062 48.12171936035156, -112.9942855834961 48.116886138916016, -112.99796295166016 48.09023666381836, -112.98053741455078 48.06575393676758, -112.94100952148438 48.04892349243164, -112.94795989990234 48.02422332763672, -112.89961242675781 48.008514404296875, -112.88496398925781 47.97304153442383, -112.92671203613281 47.94291687011719, -112.98387908935547 47.94642639160156, -113.02864837646484 47.92097473144531, -113.07555389404297 47.9153938293457, -113.0897445678711 47.90380859375, -113.0905532836914 47.890464782714844, -113.0640869140625 47.870826721191406, -113.0679702758789 47.773250579833984, -113.09268188476562 47.74308776855469, -113.15106201171875 47.73458480834961, -113.16490936279297 47.71654510498047, -113.1604995727539 47.68878936767578, -113.12995147705078 47.648338317871094, -113.15116882324219 47.59644317626953, -113.47271728515625 47.59763717651367)), POLYGON ((-112.1818618774414 48.47118377685547, -112.22827911376953 48.47878646850586, -112.58263397216797 48.474708557128906, -112.58709716796875 48.300270080566406, -113.36773681640625 48.301055908203125, -113.38793182373047 48.32835006713867, -113.33970642089844 48.36448287963867, -113.36693572998047 48.411827087402344, -113.4206771850586 48.4113655090332, -113.46344757080078 48.424922943115234, -113.48306274414062 48.43927001953125, -113.48296356201172 48.540870666503906, -113.50665283203125 48.54377746582031, -113.55496215820312 48.570377349853516, -113.61024475097656 48.56895446777344, -113.63603973388672 48.583900451660156, -113.68362426757812 48.58641815185547, -113.75214385986328 48.60650634765625, -113.7479248046875 48.63597869873047, -113.73040008544922 48.65867614746094, -113.73611450195312 48.6805305480957, -113.71166229248047 48.69151306152344, -113.70914459228516 48.70069885253906, -113.71725463867188 48.72908401489258, -113.7709732055664 48.76130294799805, -113.78099822998047 48.779563903808594, -113.77190399169922 48.81079864501953, -113.80300903320312 48.83185577392578, -113.82147979736328 48.831809997558594, -113.85028839111328 48.844482421875, -113.8742904663086 48.82929611206055, -113.91020202636719 48.83656692504883, -113.92074584960938 48.81645202636719, -113.9499740600586 48.80598831176758, -113.99457550048828 48.81758499145508, -113.98932647705078 48.84197998046875, -114.02151489257812 48.8560791015625, -114.03350830078125 48.87806701660156, -114.01712799072266 48.891597747802734, -114.01795959472656 48.903175354003906, -114.03021240234375 48.91962432861328, -114.05198669433594 48.92285919189453, -114.02249145507812 48.95323181152344, -114.05577087402344 48.9599494934082, -114.06695556640625 48.985164642333984, -114.0625 49, -112.1875 48.999996185302734, -112.19615173339844 48.910133361816406, -112.18660736083984 48.90934371948242, -112.1818618774414 48.47118377685547)), POLYGON ((-111.4214859008789 48.2177848815918, -111.6727066040039 48.21295166015625, -111.6733169555664 48.337223052978516, -111.79894256591797 48.33872604370117, -111.7992935180664 48.38493347167969, -111.99093627929688 48.38685607910156, -111.9922866821289 48.4307975769043, -112.00296783447266 48.442264556884766, -112.0142593383789 48.4371223449707, -112.02579498291016 48.446311950683594, -112.05469512939453 48.43347930908203, -112.08269500732422 48.43215560913086, -112.13877868652344 48.46461486816406, -112.17225646972656 48.46299743652344, -112.1818618774414 48.47118377685547, -112.18660736083984 48.90934371948242, -112.19615173339844 48.910133361816406, -112.1875 48.999996185302734, -111.28187561035156 49, -111.2857894897461 48.21939468383789, -111.4214859008789 48.2177848815918)), ... POLYGON ((-76.921630859375 36.55415725708008, -76.92413330078125 36.55414581298828, -77.17735290527344 36.5562858581543, -77.32005310058594 36.553916931152344, -77.33845520019531 36.561302185058594, -77.3470687866211 36.55451202392578, -77.36307525634766 36.569496154785156, -77.366455078125 36.60441589355469, -77.37902069091797 36.629825592041016, -77.38876342773438 36.630287170410156, -77.3990707397461 36.64616775512695, -77.50688171386719 36.671607971191406, -77.43629455566406 36.707862854003906, -76.95587158203125 36.94696807861328, -76.8517837524414 36.99723434448242, -76.85726928710938 36.96235275268555, -76.85057830810547 36.936927795410156, -76.82482147216797 36.92046356201172, -76.82035064697266 36.90547561645508, -76.83629608154297 36.85976791381836, -76.8530044555664 36.856231689453125, -76.86946105957031 36.81460189819336, -76.86441802978516 36.79916000366211, -76.88871765136719 36.779335021972656, -76.89978790283203 36.759891510009766, -76.898193359375 36.743560791015625, -76.914306640625 36.73955535888672, -76.92948150634766 36.70698165893555, -76.91748046875 36.70012283325195, -76.91529083251953 36.68650817871094, -76.91609954833984 36.65658187866211, -76.89785766601562 36.64243698120117, -76.89799499511719 36.62520217895508, -76.91182708740234 36.61620330810547, -76.91493225097656 36.58538055419922, -76.93571472167969 36.56552505493164, -76.921630859375 36.55415725708008)), POLYGON ((-79.14432525634766 36.546058654785156, -79.2170639038086 36.549781799316406, -79.09967803955078 37.05594253540039, -79.03742980957031 37.029998779296875, -79.01966857910156 37.03520965576172, -78.99878692626953 37.02912521362305, -78.9806900024414 37.04657745361328, -78.91504669189453 37.02106475830078, -78.89128112792969 37.01408386230469, -78.89706420898438 36.984092712402344, -78.8153305053711 36.9886360168457, -78.78662109375 36.96128845214844, -78.77404022216797 36.966407775878906, -78.77387237548828 36.99044418334961, -78.75259399414062 36.9929313659668, -78.76262664794922 37.00688552856445, -78.75814819335938 37.0146369934082, -78.75004577636719 37.012908935546875, -78.73038482666016 36.938751220703125, -78.74974060058594 36.92539978027344, -78.72650909423828 36.91294479370117, -78.69314575195312 36.87836456298828, -78.69124603271484 36.867042541503906, -78.6691665649414 36.85320281982422, -78.6695556640625 36.84141159057617, -78.68373107910156 36.828575134277344, -78.6702651977539 36.813289642333984, -78.67931365966797 36.803680419921875, -78.66378784179688 36.76618957519531, -78.68757629394531 36.74464797973633, -78.646728515625 36.702415466308594, -78.62510681152344 36.67677307128906, -78.5575942993164 36.649269104003906, -78.5505599975586 36.63844680786133, -78.5550765991211 36.633419036865234, -78.57862854003906 36.636383056640625, -78.61848449707031 36.655517578125, -78.64364624023438 36.688385009765625, -78.66034698486328 36.69231033325195, -78.68263244628906 36.686195373535156, -78.69619750976562 36.672908782958984, -78.71710968017578 36.58290481567383, -78.7413330078125 36.5572624206543, -78.73738861083984 36.54607391357422, -78.79669952392578 36.54353332519531, -79.14432525634766 36.546058654785156)), POLYGON ((-79.43775177001953 37.61595916748047, -79.45834350585938 37.60338592529297, -79.44351196289062 37.569618225097656, -79.46684265136719 37.55156326293945, -79.50364685058594 37.53826904296875, -79.5832748413086 37.58317565917969, -79.57156372070312 37.60060501098633, -79.68380737304688 37.663482666015625, -79.66374206542969 37.69330978393555, -79.67378997802734 37.69857406616211, -79.68485260009766 37.73827362060547, -79.67514038085938 37.76428985595703, -79.61547088623047 37.856468200683594, -79.60111999511719 37.86442184448242, -79.64639282226562 37.877235412597656, -79.61421203613281 37.93492126464844, -79.54563903808594 37.987770080566406, -79.51864624023438 38.025848388671875, -79.5250244140625 38.04523468017578, -79.48284912109375 38.085365295410156, -79.1783447265625 37.91357421875, -79.1498031616211 37.88948059082031, -79.14042663574219 37.86104965209961, -79.1620101928711 37.80998229980469, -79.18153381347656 37.7974739074707, -79.20051574707031 37.78678512573242, -79.23248291015625 37.80900192260742, -79.25855255126953 37.802738189697266, -79.27848052978516 37.783409118652344, -79.28265380859375 37.76340103149414, -79.30659484863281 37.742191314697266, -79.30562591552734 37.726341247558594, -79.31986999511719 37.71388626098633, -79.32745361328125 37.69110870361328, -79.34122467041016 37.68364715576172, -79.34822082519531 37.66087341308594, -79.39974212646484 37.629249572753906, -79.43775177001953 37.61595916748047), (-79.34247589111328 37.71037673950195, -79.33568572998047 37.74176025390625, -79.36357116699219 37.739524841308594, -79.38802337646484 37.71693420410156, -79.38839721679688 37.70876693725586, -79.37145233154297 37.70585250854492, -79.34247589111328 37.71037673950195)), POLYGON ((-80.12474822998047 37.12510299682617, -80.14044952392578 37.12839126586914, -80.15437316894531 37.1140251159668, -80.16817474365234 37.112361907958984, -80.17552947998047 37.124446868896484, -80.1921615600586 37.233375549316406, -80.2585678100586 37.308982849121094, -80.25981140136719 37.34251403808594, -80.20427703857422 37.3759651184082, -80.15182495117188 37.38347244262695, -80.08169555664062 37.41627502441406, -79.8650131225586 37.32817840576172, -79.84698486328125 37.30721664428711, -79.85009002685547 37.222354888916016, -79.8826904296875 37.2112922668457, -79.9231948852539 37.15924072265625, -79.95780944824219 37.140403747558594, -79.99276733398438 37.14966583251953, -80.00562286376953 37.17116928100586, -80.02654266357422 37.1748161315918, -80.09751892089844 37.15562438964844, -80.12474822998047 37.12510299682617), (-79.89704132080078 37.244110107421875, -79.90105438232422 37.27894973754883, -79.89382934570312 37.28816223144531, -79.9354476928711 37.32225036621094, -80.00720977783203 37.304466247558594, -80.01111602783203 37.2830696105957, -80.00724029541016 37.270904541015625, -79.99628448486328 37.272037506103516, -79.99830627441406 37.24614715576172, -79.98088073730469 37.2437858581543, -79.95658874511719 37.226139068603516, -79.9304428100586 37.22213363647461, -79.9132080078125 37.225650787353516, -79.89704132080078 37.244110107421875)), POLYGON ((-87.74845123291016 44.96162796020508, -87.83988952636719 44.92733383178711, -87.83091735839844 44.873355865478516, -87.98568725585938 44.720481872558594, -87.98307800292969 44.67727279663086, -88.23519134521484 44.6751708984375, -88.23552703857422 44.58895492553711, -88.59586334228516 44.591880798339844, -88.59857940673828 44.6767463684082, -89.2162094116211 44.680850982666016, -89.21665954589844 45.03134536743164, -88.97592163085938 45.03107452392578, -88.97846221923828 45.11920928955078, -88.63270568847656 45.11879348754883, -88.6341552734375 45.20695114135742, -88.67102813720703 45.208099365234375, -88.66957092285156 45.37849426269531, -88.42241668701172 45.37583541870117, -88.30050659179688 45.372520446777344, -88.30354309082031 45.20259094238281, -88.18257141113281 45.20054626464844, -88.1829605102539 45.11468505859375, -88.1157455444336 45.114925384521484, -88.11431121826172 45.02769088745117, -87.93888092041016 45.02211380004883, -87.93751525878906 44.997440338134766, -87.75312042236328 44.992431640625, -87.74845123291016 44.96162796020508)), POLYGON ((-114.51984405517578 33.02766799926758, -114.55830383300781 33.0367431640625, -114.60913848876953 33.02696228027344, -114.6331787109375 33.03352737426758, -114.64437103271484 33.04437255859375, -114.66316223144531 33.038883209228516, -114.71056365966797 33.09534454345703, -114.70867156982422 33.122337341308594, -114.67733001708984 33.167213439941406, -114.67926025390625 33.22455978393555, -114.68692016601562 33.23922348022461, -114.6769027709961 33.267982482910156, -114.73463439941406 33.3056755065918, -114.70281219482422 33.352386474609375, -114.7241439819336 33.41102981567383, -114.64430236816406 33.41908645629883, -114.6297836303711 33.439395904541016, -114.62030029296875 33.468570709228516, -114.59729766845703 33.48609924316406, -114.58627319335938 33.50941848754883, -114.52863311767578 33.5600471496582, -114.53945922851562 33.580482482910156, -114.52638244628906 33.62211227416992, -114.52447509765625 33.66548156738281, -114.53564453125 33.68271255493164, -114.49488830566406 33.70834732055664, -114.5094985961914 33.74317932128906, -114.50376892089844 33.77169418334961, -114.52033233642578 33.826011657714844, -114.51093292236328 33.84194564819336, -114.52017211914062 33.86290740966797, -114.49739837646484 33.925018310546875, -114.52484130859375 33.952396392822266, -114.51741790771484 33.96504592895508, -114.42819213867188 34.02982711791992, -114.4232406616211 34.07831573486328, -114.40937805175781 34.102638244628906, -114.32201385498047 34.14128112792969, -114.28458404541016 34.17121505737305, -114.23499298095703 34.18620681762695, -114.14913177490234 34.266963958740234, -114.12445068359375 34.272605895996094, -114.13334655761719 34.31453323364258, -114.15263366699219 34.33643341064453, -114.05349731445312 34.303016662597656, -114.02969360351562 34.279476165771484, -114.007568359375 34.27315139770508, -113.99447631835938 34.25141906738281, -113.85706329345703 34.25224304199219, -113.82688903808594 34.22346878051758, -113.78794860839844 34.241458892822266, -113.75486755371094 34.237361907958984, -113.73086547851562 34.24516677856445, -113.70672607421875 34.22339630126953, -113.66130065917969 34.20793914794922, -113.59542083740234 34.23195266723633, -113.5514907836914 34.2891845703125, -113.51676177978516 34.31419372558594, -113.42485809326172 34.304080963134766, -113.35930633544922 34.306556701660156, -113.3394775390625 34.31048583984375, -113.32621765136719 34.322349548339844, -113.33061218261719 34.01191329956055, -113.32804870605469 33.37895202636719, -113.32926177978516 32.51881408691406, -113.32837677001953 32.04356002807617, -114.82096862792969 32.48711395263672, -114.80860137939453 32.61599349975586, -114.72126007080078 32.72080993652344, -114.71190643310547 32.73496627807617, -114.69325256347656 32.74137878417969, -114.60315704345703 32.72623825073242, -114.60273742675781 32.73583984375, -114.57117462158203 32.73739242553711, -114.57142639160156 32.748783111572266, -114.55996704101562 32.7488899230957, -114.56079864501953 32.76070785522461, -114.54222106933594 32.760704040527344, -114.54240417480469 32.77118682861328, -114.52931213378906 32.771366119384766, -114.53429412841797 32.788002014160156, -114.52543640136719 32.80986785888672, -114.46065521240234 32.84537887573242, -114.47566223144531 32.93586730957031, -114.46760559082031 32.97774887084961, -114.51984405517578 33.02766799926758)), POLYGON ((-107.19483947753906 34.583518981933594, -107.71780395507812 34.584259033203125, -108.2269058227539 34.58328628540039, -109.04801177978516 34.591739654541016, -109.0459976196289 34.954612731933594, -108.458740234375 34.95609664916992, -108.4584732055664 35.31293869018555, -107.72924041748047 35.31460189819336, -107.72345733642578 35.357208251953125, -107.61972045898438 35.356040954589844, -107.61988830566406 35.31563949584961, -107.29420471191406 35.31229019165039, -107.22771453857422 35.311763763427734, -107.18017578125 35.2252311706543, -107.05371856689453 34.96342086791992, -107.01132202148438 34.87645721435547, -106.70357513427734 34.87855529785156, -106.6739501953125 34.91294479370117, -106.4139404296875 34.907501220703125, -106.4137191772461 34.89750289916992, -106.40196990966797 34.89678955078125, -106.39997863769531 34.8726692199707, -106.45438385009766 34.8715934753418, -106.45154571533203 34.618465423583984, -106.46049499511719 34.61820983886719, -106.46228790283203 34.529632568359375, -106.40431213378906 34.52790451049805, -106.40634155273438 34.45069122314453, -106.4516830444336 34.44487380981445, -106.76272583007812 34.54032516479492, -106.87151336669922 34.58189392089844, -107.19483947753906 34.583518981933594)), POLYGON ((-76.39569091796875 37.10770797729492, -76.40270233154297 37.0905647277832, -76.43445587158203 37.08903884887695, -76.46367645263672 37.10334396362305, -76.56945037841797 37.22797775268555, -76.59126281738281 37.23149490356445, -76.60050964355469 37.24090576171875, -76.65472412109375 37.252174377441406, -76.67423248291016 37.26545715332031, -76.68669128417969 37.29002380371094, -76.71446228027344 37.28975296020508, -76.74456787109375 37.34389114379883, -76.74317932128906 37.36655044555664, -76.72750854492188 37.370079040527344, -76.69979095458984 37.36309814453125, -76.66998291015625 37.371646881103516, -76.59503936767578 37.291297912597656, -76.42466735839844 37.207298278808594, -76.41299438476562 37.15239334106445, -76.3968734741211 37.173030853271484, -76.36378479003906 37.146427154541016, -76.33731842041016 37.17700958251953, -76.28567504882812 37.12209701538086, -76.39569091796875 37.10770797729492)), POLYGON ((-77.53178405761719 38.56505584716797, -77.72093963623047 38.84042739868164, -77.70687103271484 38.877166748046875, -77.67792510986328 38.88491439819336, -77.65735626220703 38.94068908691406, -77.6265869140625 38.936195373535156, -77.5898666381836 38.894527435302734, -77.5555648803711 38.88502883911133, -77.54845428466797 38.85557174682617, -77.53840637207031 38.850589752197266, -77.529541015625 38.83427810668945, -77.50945281982422 38.8410758972168, -77.50531768798828 38.815696716308594, -77.49527740478516 38.81071090698242, -77.4970474243164 38.79167556762695, -77.44922637939453 38.79710388183594, -77.42799377441406 38.778961181640625, -77.41386413574219 38.744056701660156, -77.40619659423828 38.74223709106445, -77.39910125732422 38.753562927246094, -77.38436889648438 38.744483947753906, -77.38087463378906 38.71592712402344, -77.35903930664062 38.72406005859375, -77.32837677001953 38.71994400024414, -77.31426239013672 38.70405960083008, -77.2712631225586 38.690391540527344, -77.22759246826172 38.65072250366211, -77.30361938476562 38.50191116333008, -77.37589263916016 38.52420425415039, -77.43054962158203 38.56911849975586, -77.48469543457031 38.59587478637695, -77.53178405761719 38.56505584716797)), POLYGON ((-111.37152099609375 44.74516296386719, -111.3683853149414 45.34981918334961, -111.3494873046875 45.34947967529297, -111.34896087646484 45.63465881347656, -111.52933502197266 45.63527297973633, -111.52919006347656 45.65133285522461, -111.55271911621094 45.651397705078125, -111.55352020263672 45.6641960144043, -111.5737075805664 45.66352462768555, -111.5729751586914 45.68008041381836, -111.59786987304688 45.680519104003906, -111.59779357910156 45.69704055786133, -111.61749267578125 45.6977653503418, -111.61820220947266 45.70965576171875, -111.63720703125 45.709957122802734, -111.6374282836914 45.72325134277344, -111.653076171875 45.72282409667969, -111.65415954589844 45.73790740966797, -111.71434020996094 45.73769760131836, -111.7155990600586 45.77112579345703, -111.78907775878906 45.777931213378906, -111.79002380371094 45.79715347290039, -111.76252746582031 45.802860260009766, -111.730224609375 45.795536041259766, -111.70305633544922 45.79845428466797, -111.65892791748047 45.8418083190918, -111.62377166748047 45.85527038574219, -111.60369110107422 45.88026428222656, -111.56310272216797 45.89813995361328, -111.55003356933594 45.915855407714844, -111.52613830566406 45.92498779296875, -111.50170135498047 45.92359161376953, -111.46724700927734 45.967262268066406, -111.46504211425781 45.988502502441406, -111.42523956298828 45.99665451049805, -111.41201782226562 46.078182220458984, -111.38861846923828 46.09828567504883, -111.3441162109375 46.11814880371094, -111.34532165527344 46.182376861572266, -111.06291961669922 46.18952941894531, -110.78948211669922 46.18783950805664, -110.43590545654297 46.1871223449707, -110.43553924560547 46.17658233642578, -110.2987060546875 46.17701721191406, -110.30351257324219 45.78554153442383, -110.21784210205078 45.78583526611328, -110.21027374267578 45.347747802734375, -110.22454833984375 45.3475456237793, -110.21772003173828 45.16933059692383, -110.05651092529297 45.171199798583984, -109.79487609863281 45.17312240600586, -109.79865264892578 44.99958038330078, -109.99478912353516 45.00285339355469, -110.39200592041016 44.998687744140625, -110.42889404296875 44.992347717285156, -111.05265045166016 44.995765686035156, -111.05084228515625 44.6645622253418, -111.05078887939453 44.47339630126953, -111.09385681152344 44.48619842529297, -111.12814331054688 44.500831604003906, -111.13358306884766 44.527976989746094, -111.16946411132812 44.54526138305664, -111.17798614501953 44.56492614746094, -111.2187271118164 44.573246002197266, -111.23345184326172 44.602638244628906, -111.2190170288086 44.61805725097656, -111.22319030761719 44.626983642578125, -111.26988220214844 44.64228820800781, -111.26942443847656 44.67387771606445, -111.29488372802734 44.683013916015625, -111.31468963623047 44.70526885986328, -111.31843566894531 44.72793960571289, -111.34918975830078 44.726253509521484, -111.37152099609375 44.74516296386719))], dtype='object', name='county', length=3085))
This is the basic data structure. To enable geometric functionality provided by Xvec, you need to turn the counties
index, which is by default a PandasIndex
, into an xvec.GeometryIndex
. The easiest method is to use the .xvec
accessor and the set_geom_indexes
method.
pop1960 = pop1960.xvec.set_geom_indexes("county", crs=counties.crs)
pop1960.xindexes
Indexes:
county GeometryIndex (crs=EPSG:4326)
However, it is often better to use GeoPandas instead at this dimensionality. The relationship between GeoDataFrames and vector data cubes is similar to that of a DataFrame and a DataArray. With lower dimensionality, DataFrame is often a better choice. With a higher one, DataArray is a more fitting data structure.
The meaningful DataArray#
The counties
data frame has time (1960, 1970, 1980, 1990) encoded in column names, which is not ideal, so you can turn it into a DataArray indexed by geometry and by time.
population = xr.DataArray(
counties[["PO60", "PO70", "PO80", "PO90"]],
coords=(counties.geometry, [1960, 1970, 1980, 1990]),
dims=("county", "year"),
).xvec.set_geom_indexes("county", crs=counties.crs)
population
<xarray.DataArray (county: 3085, year: 4)> array([[ 4304, 3987, 3764, 4076], [ 3889, 3655, 5811, 6295], [ 17884, 17405, 28979, 30948], ..., [ 21583, 33203, 44189, 53427], [ 50164, 111102, 166665, 250377], [ 39260, 43766, 55800, 65077]]) Coordinates: * county (county) object POLYGON ((-95.34258270263672 48.54670333862305, ... * year (year) int64 1960 1970 1980 1990 Indexes: county GeometryIndex (crs=EPSG:4326)
- county: 3085
- year: 4
- 4304 3987 3764 4076 3889 3655 ... 250377 39260 43766 55800 65077
array([[ 4304, 3987, 3764, 4076], [ 3889, 3655, 5811, 6295], [ 17884, 17405, 28979, 30948], ..., [ 21583, 33203, 44189, 53427], [ 50164, 111102, 166665, 250377], [ 39260, 43766, 55800, 65077]])
- county(county)objectPOLYGON ((-95.34258270263672 48....
- crs :
- epsg:4326
array([<POLYGON ((-95.343 48.547, -95.341 48.715, -95.094 48.717, -95.095 48.912, -...>, <POLYGON ((-118.851 47.95, -118.847 48.478, -118.869 48.479, -118.87 48.647,...>, <POLYGON ((-117.438 48.044, -117.541 48.043, -117.536 47.79, -117.607 47.798...>, ..., <POLYGON ((-76.396 37.108, -76.403 37.091, -76.434 37.089, -76.464 37.103, -...>, <POLYGON ((-77.532 38.565, -77.721 38.84, -77.707 38.877, -77.678 38.885, -7...>, <POLYGON ((-111.372 44.745, -111.368 45.35, -111.349 45.349, -111.349 45.635...>], dtype=object)
- year(year)int641960 1970 1980 1990
array([1960, 1970, 1980, 1990])
- yearPandasIndex
PandasIndex(Int64Index([1960, 1970, 1980, 1990], dtype='int64', name='year'))
- countyGeometryIndex (crs=EPSG:4326)
<xvec.index.GeometryIndex object at 0x14fe517e0>
This is the simplest form of a vector data cube that is useful.
The Dataset#
A proper data cube is represented as a Dataset in the Xarray world. You can index a dataset by geometry in precisely the same way as a DataArray. For example, you can use the counties
GeoDataFrame and turn it into a Dataset with population, unemployment rate, divorce rate and median age.
cube = xr.Dataset(
data_vars=dict(
population=(["county", "year"], counties[["PO60", "PO70", "PO80", "PO90"]]),
unemployment=(["county", "year"], counties[["UE60", "UE70", "UE80", "UE90"]]),
divorce=(["county", "year"], counties[["DV60", "DV70", "DV80", "DV90"]]),
age=(["county", "year"], counties[["MA60", "MA70", "MA80", "MA90"]]),
),
coords=dict(county=counties.geometry, year=[1960, 1970, 1980, 1990]),
).xvec.set_geom_indexes("county", crs=counties.crs)
cube
<xarray.Dataset> Dimensions: (county: 3085, year: 4) Coordinates: * county (county) object POLYGON ((-95.34258270263672 48.54670333862... * year (year) int64 1960 1970 1980 1990 Data variables: population (county, year) int64 4304 3987 3764 4076 ... 43766 55800 65077 unemployment (county, year) float64 7.9 9.0 5.903 ... 5.444 7.018 5.489 divorce (county, year) float64 1.859 2.62 3.747 ... 2.725 4.782 7.415 age (county, year) float64 28.8 30.5 34.5 ... 26.4 28.97 35.33 Indexes: county GeometryIndex (crs=EPSG:4326)
- county: 3085
- year: 4
- county(county)objectPOLYGON ((-95.34258270263672 48....
- crs :
- epsg:4326
array([<POLYGON ((-95.343 48.547, -95.341 48.715, -95.094 48.717, -95.095 48.912, -...>, <POLYGON ((-118.851 47.95, -118.847 48.478, -118.869 48.479, -118.87 48.647,...>, <POLYGON ((-117.438 48.044, -117.541 48.043, -117.536 47.79, -117.607 47.798...>, ..., <POLYGON ((-76.396 37.108, -76.403 37.091, -76.434 37.089, -76.464 37.103, -...>, <POLYGON ((-77.532 38.565, -77.721 38.84, -77.707 38.877, -77.678 38.885, -7...>, <POLYGON ((-111.372 44.745, -111.368 45.35, -111.349 45.349, -111.349 45.635...>], dtype=object)
- year(year)int641960 1970 1980 1990
array([1960, 1970, 1980, 1990])
- population(county, year)int644304 3987 3764 ... 55800 65077
array([[ 4304, 3987, 3764, 4076], [ 3889, 3655, 5811, 6295], [ 17884, 17405, 28979, 30948], ..., [ 21583, 33203, 44189, 53427], [ 50164, 111102, 166665, 250377], [ 39260, 43766, 55800, 65077]])
- unemployment(county, year)float647.9 9.0 5.903 ... 5.444 7.018 5.489
array([[ 7.9 , 9. , 5.9025788 , 3.89479009], [ 8.2 , 15.4 , 15.42288557, 16.8115942 ], [10.1 , 9. , 13.57406431, 10.70079408], ..., [ 2.5 , 3.10506508, 5.03704493, 4.1028878 ], [ 3.3 , 2.36155862, 3.70888552, 3.35398107], [ 5.21803859, 5.44429066, 7.01794317, 5.48855304]])
- divorce(county, year)float641.859 2.62 3.747 ... 4.782 7.415
array([[ 1.85897436, 2.61980831, 3.74659401, 7.38853503], [ 2.86327845, 3.68600683, 6.6254417 , 11.54313487], [ 2.71144662, 2.97637795, 5.44822257, 9.12321222], ..., [ 1.11322292, 1.55032333, 3.25763881, 4.85074627], [ 1.67239146, 1.46834319, 3.74220727, 5.75017712], [ 2.77758585, 2.72460364, 4.78226375, 7.4145588 ]])
- age(county, year)float6428.8 30.5 34.5 ... 26.4 28.97 35.33
array([[28.8 , 30.5 , 34.5 , 35.5 ], [25.9 , 27.1 , 27.2 , 32.8 ], [29.6 , 31.8 , 28.7 , 34.5 ], ..., [24.4 , 24.4 , 29.8 , 34. ], [22.3 , 21.8 , 25.66666667, 28.46666667], [28.25 , 26.4 , 28.96666667, 35.33333333]])
- yearPandasIndex
PandasIndex(Int64Index([1960, 1970, 1980, 1990], dtype='int64', name='year'))
- countyGeometryIndex (crs=EPSG:4326)
<xvec.index.GeometryIndex object at 0x16451dbd0>
Now you have a Dataset with 4 variables, indexed by the year and county geometry—a so-called vector data cube.
You can check that it has a dimension with geometry:
cube.xvec.geom_coords
Coordinates:
* county (county) object POLYGON ((-95.34258270263672 48.54670333862305, ...
And that this dimension is properly indexed by the GeometryIndex
.
cube.xvec.geom_coords_indexed
Coordinates:
* county (county) object POLYGON ((-95.34258270263672 48.54670333862305, ...
What next?