0

I am using these dataset " dataset tempat perlancongan Malaysia.csv" . In that I'm Passing the latitude and longitude for plotting the plot plot for spatial coordinate vs numerical feature .

error I got =

Value Error: Invalid property specified for object of type plotly.graph_objs.Choropleth: 'lat'

  • what's the code? that gave you the error? – Ran A Sep 06 '22 at 09:12
  • If you provide the dataset and how you are passing the latitude and longitude it would be easier to guess what went wrong. – Claudio Sep 06 '22 at 09:49
  • Please clarify your specific problem or provide additional details to highlight exactly what you need. As it's currently written, it's hard to tell exactly what you're asking. – Community Sep 06 '22 at 10:49

1 Answers1

0
  • I don't speak Malay so can't fully find data set you partially reference. Have used this one pelancongan data
  • it's appears you have not understood what a choropleth is. A choropleth uses polygons as the geometry, not points. From fact you are trying to pass lat and the data I have found provided latitude and longitude your data supports a scatter not a choropleth
import requests, io
import plotly.express as px

# https://www.data.gov.my/data/en_US/dataset/lokasi-tempat-pelancongan-mengikut-daerah-di-negeri-selangor/resource/18b5c1e0-e362-41a2-935c-c35795df9d17
df = pd.read_csv(
    io.StringIO(
        requests.get(
            "https://www.data.gov.my/data/en_US/datastore/dump/18b5c1e0-e362-41a2-935c-c35795df9d17"
        ).text
    )
)

px.scatter_geo(df, lat="LATITUDE", lon="LONGITUDE", hover_data=["NAMA"]).update_layout(
    geo_scope="asia", geo_fitbounds="locations"
)

enter image description here

mapbox ***

px.scatter_mapbox(
    df,
    lat="LATITUDE",
    lon="LONGITUDE",
    hover_data=["NAMA"],
    mapbox_style="carto-positron",
)

enter image description here

Rob Raymond
  • 29,118
  • 3
  • 14
  • 30