示例#1
0
    def _convertShapefileToGeoJson(self, item, tmpdir):
        # TODO need to figure out convention here
        # assumes a shapefile is stored as a single item with a certain name
        # and all of the shapefiles as files within that item with
        # the same name.
        #
        # ex: item['name'] = myshapefile
        #     # abuse of notation for item.files
        #     item.files[0]['name'] =  myshapefile.cpg
        #     item.files[1]['name'] =  myshapefile.dbf
        #     item.files[2]['name'] =  myshapefile.prj
        #     item.files[3]['name'] =  myshapefile.shp
        #     item.files[4]['name'] =  myshapefile.shx

        from gaia.pandas import GeopandasReader, GeopandasWriter
        reader = GeopandasReader()
        reader.file_name = os.path.join(tmpdir, item['name'])
        geojsonFilepath = os.path.join(tmpdir, item['name'] +
                                       PluginSettings.GEOJSON_EXTENSION)
        writer = GeopandasWriter()
        writer.file_name = geojsonFilepath
        writer.format = 'GeoJSON'
        writer.set_input(port=reader.get_output())
        writer.run()
        return geojsonFilepath
示例#2
0
    def _convertToGeoJson(self, item, tmpdir):
        from gaia.pandas import GeopandasReader, GeopandasWriter

        reader = GeopandasReader()
        reader.file_name = os.path.join(tmpdir, item["name"])
        geojsonFile = os.path.join(tmpdir, item["name"] + PluginSettings.GEOJSON_EXTENSION)
        writer = GeopandasWriter()
        writer.file_name = geojsonFile
        writer.format = "GeoJSON"
        writer.set_input(port=reader.get_output())
        writer.run()
        return geojsonFile
示例#3
0
class GeopandasPlotTest(TestCase):

    """Test the geopandas plotter."""

    def setUp(self):  # noqa
        """Read a small geojson file."""
        TestCase.setUp(self)
        self.reader = GeopandasReader()
        self.reader.file_name = self.data_path('geopoints.json')

    def _plot_geojson(self, ext):
        """Read a small geojson file and save a plot."""

        plotter = GeopandasPlot()
        plotter.set_input(port=self.reader.get_output())
        plotter.file_name = self.output_path('geopoints.' + ext)

        plotter.run()
        self.assertTrue(os.path.exists(plotter.file_name))

    def test_plot_geojson_png(self):
        """Create a png image."""
        self._plot_geojson('png')

    def test_plot_geojson_pdf(self):
        """Create a pdf image."""
        self._plot_geojson('pdf')
示例#4
0
 def setUp(self):  # noqa
     """Read a small geojson file."""
     TestCase.setUp(self)
     self.reader = GeopandasReader()
     self.reader.file_name = self.data_path('geopoints.json')
示例#5
0
 def reader(self, fname):
     """Read a file from the local data store."""
     reader = GeopandasReader()
     reader.file_name = self.data_path(fname)
     return reader