Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AttributeError: 'FeatureCollection' object has no attribute 'has_raster' #252

Open
snat07 opened this issue Jun 19, 2019 · 2 comments
Open

Comments

@snat07
Copy link

snat07 commented Jun 19, 2019

>>> fc._results
[[GeoFeature(Polygon, {'C_Distri': '01', 'N_Distri': 'Ciutat Vella', 'C_Barri': '04', 'N_Barri': 'Sant Pere, Santa Caterina i la Ribera', 'Homes': 11466, 'Dones': 11390, 'Area': 1114298.81253, 'Perim': 4658.031512, 'Coord_X': 431822.634373, 'Coord_Y': 4582222.36348, 'WEB_1': 'http://www.bcn.cat/ciutatvella', 'WEB_2': 'http://www.bcn.cat/estadistica/catala/dades/inf/anuari/index.htm', 'WEB_3': 'http://www.bcn.cat/estadistica/catala/dades/guiadt01/index.htm', 'WEB_4': 'http://www.bcn.cat/estadistica/catala/dades/inf/barris/a2011/barri4.pdf'}), GeoFeature(Polygon, {'C_Distri': '02', 'N_Distri': 'Eixample', 'C_Barri': '05', 'N_Barri': 'el Fort Pienc', 'Homes': 15039, 'Dones': 16924, 'Area': 928901.046575, 'Perim': 4175.971325, 'Coord_X': 431670.741604, 'Coord_Y': 4583403.35904, 'WEB_1': 'http://www.bcn.cat/eixample', 'WEB_2': 'http://www.bcn.cat/estadistica/catala/dades/inf/anuari/index.htm', 'WEB_3': 'http://www.bcn.cat/estadistica/catala/dades/guiadt02/index.htm', 'WEB_4': 'http://www.bcn.cat/estadistica/catala/dades/inf/barris/a2011/barri5.pdf'}), GeoFeature(Polygon, {'C_Distri': '02', 'N_Distri': 'Eixample', 'C_Barri': '06', 'N_Barri': 'la Sagrada Família', 'Homes': 23686, 'Dones': 27937, 'Area': 1050991.15274, 'Perim': 4336.621674, 'Coord_X': 431269.360994, 'Coord_Y': 4584298.69238, 'WEB_1': 'http://www.bcn.cat/eixample', 'WEB_2': 'http://www.bcn.cat/estadistica/catala/dades/inf/anuari/index.htm', 'WEB_3': 'http://www.bcn.cat/estadistica/catala/dades/guiadt02/index.htm', 'WEB_4': 'http://www.bcn.cat/estadistica/catala/dades/inf/barris/a2011/barri6.pdf'}), GeoFeature(Polygon, {'C_Distri': '02', 'N_Distri': 'Eixample', 'C_Barri': '07', 'N_Barri': "la Dreta de l'Eixample", 'Homes': 20240, 'Dones': 23754, 'Area': 2123404.58138, 'Perim': 6460.307377, 'Coord_X': 430556.145518, 'Coord_Y': 4583021.61979, 'WEB_1': 'http://www.bcn.cat/eixample', 'WEB_2': 'http://www.bcn.cat/estadistica/catala/dades/inf/anuari/index.htm', 'WEB_3': 'http://www.bcn.cat/estadistica/catala/dades/guiadt02/index.htm', 'WEB_4': 'http://www.bcn.cat/estadistica/catala/dades/inf/barris/a2011/barri7.pdf'}), GeoFeature(Polygon, {'C_Distri': '10', 'N_Distri': 'Sant Martí', 'C_Barri': '66', 'N_Barri': 'el Parc i la Llacuna del Poblenou', 'Homes': 7231, 'Dones': 7719, 'Area': 1114038.06822, 'Perim': 5339.802362, 'Coord_X': 432407.0575, 'Coord_Y': 4583524.05951, 'WEB_1': 'http://www.bcn.cat/santmarti', 'WEB_2': 'http://www.bcn.cat/estadistica/catala/dades/inf/anuari/index.htm', 'WEB_3': 'http://www.bcn.cat/estadistica/catala/dades/guiadt10/index.htm', 'WEB_4': 'http://www.bcn.cat/estadistica/catala/dades/inf/barris/a2011/barri66.pdf'}), GeoFeature(Polygon, {'C_Distri': '10', 'N_Distri': 'Sant Martí', 'C_Barri': '68', 'N_Barri': 'el Poblenou', 'Homes': 16353, 'Dones': 17289, 'Area': 1544597.83251, 'Perim': 6358.989689, 'Coord_X': 433421.785699, 'Coord_Y': 4583668.81356, 'WEB_1': 'http://www.bcn.cat/santmarti', 'WEB_2': 'http://www.bcn.cat/estadistica/catala/dades/inf/anuari/index.htm', 'WEB_3': 'http://www.bcn.cat/estadistica/catala/dades/guiadt10/index.htm', 'WEB_4': 'http://www.bcn.cat/estadistica/catala/dades/inf/barris/a2011/barri68.pdf'})],
 [GeoFeature(Point, {}), GeoFeature(Point, {}), GeoFeature(Point, {}), GeoFeature(Point, {}), GeoFeature(Point, {}), GeoFeature(Point, {}), GeoFeature(Point, {})]]
>>> fc._repr_html_()
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-58-6b748fee2593> in <module>
----> 1 fc._repr_html_()

~/anaconda3/envs/telluric36/lib/python3.6/site-packages/telluric/plotting.py in _repr_html_(self)
    159         if (
    160             isinstance(self, BaseCollection) and
--> 161             self[0].has_raster
    162         ):
    163             return self._run_in_tileserver(capture="Feature collection of rasters")

AttributeError: 'FeatureCollection' object has no attribute 'has_raster'
@drnextgis
Copy link
Contributor

Cannot reproduce it here. Can you please show how are you creating the fc object?

>>> import telluric
>>> from shapely.geometry import Point, Polygon
>>> from telluric import (
...     GeoFeature,
...     FeatureCollection,
...     GeoVector,
... )
>>> 
>>> fc = FeatureCollection(
...     (
...         GeoFeature(GeoVector(Point(0, 0)), {"a": 1}),
...         GeoFeature(
...             GeoVector(Polygon(((0, 0), (1, 1), (2, 0)))),
...             {"b": 2},
...         ),
...     )
... )
>>> fc._repr_html_()[:25]
/home/denis/satellogic/telluric/telluric/plotting.py:171: UserWarning: Plotting a limited representation of the data, use the .plot() method for further customization
  "Plotting a limited representation of the data, use the .plot() method for further customization")
'<div style="width:100%;">'

@astrojuanlu
Copy link
Contributor

I think the problem is that the first element of the FeatureCollection was a FeatureCollection itself, which in principle is not supported:

AttributeError: 'FeatureCollection' object has no attribute 'has_raster'

Perhaps it should give a better error message.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants