<SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
 Subsetting grids using shapefiles.
Step1:  We can now subset the 0.1x0.1 degree regular grid with the shapefiles from http
Step2:  We can the plot the resulting grid using a simple scatterplot.
Step3:  Behind the scenes this functionality uses the get_shp_grid_points function of the grid object.
We can also use this directly using any ogr.Geometry object.
<ASSISTANT_TASK:>
Python Code:
import pygeogrids.grids as grids
import pygeogrids.shapefile as shapefile
import numpy as np
import os
testgrid = grids.genreg_grid(0.1, 0.1)
Explanation: Subsetting grids using shapefiles.
End of explanation
austria = shapefile.get_gad_grid_points(
    testgrid, os.path.join('/home', os.environ['USER'], 'Downloads', 'gadm', 'gadm28_levels.shp.zip'), 0, name='Austria')
Explanation: We can now subset the 0.1x0.1 degree regular grid with the shapefiles from http://biogeo.ucdavis.edu/data/gadm2.8/gadm28_levels.shp.zip which were downloaded/extracted to ~/Downloads/gadm
End of explanation
import matplotlib.pyplot as plt
%matplotlib inline
plt.scatter(austria.arrlon, austria.arrlat)
Explanation: We can the plot the resulting grid using a simple scatterplot.
End of explanation
ring = ogr.Geometry(ogr.wkbLinearRing)
ring.AddPoint(14, 47)
ring.AddPoint(14, 48)
ring.AddPoint(16, 48)
ring.AddPoint(16, 47)
ring.AddPoint(14, 47)
poly = ogr.Geometry(ogr.wkbPolygon)
poly.AddGeometry(ring)
subgrid = austria.get_shp_grid_points(poly)
plt.scatter(austria.arrlon, austria.arrlat)
plt.scatter(subgrid.arrlon, subgrid.arrlat, c='orange')
Explanation: Behind the scenes this functionality uses the get_shp_grid_points function of the grid object.
We can also use this directly using any ogr.Geometry object.
End of explanation
<END_TASK>