Files
d4c-datapkg-statistical/experiments/vector_tiles.ipynb
T
2025-05-24 13:37:31 -04:00

3.0 KiB

In [1]:
import pandas as pd

This is required for tippecanoe to guess the proper types for the fields

In [ ]:
tippecanoe_df_types = pd.DataFrame(da_df_cop_df.dtypes)

attributes_types = [] 
for row in tippecanoe_df_types.itertuples():
    # This is what it should look like --attribute-type=count_total_1:int
    column_name = row[0]
    column_type = str(row[1])
    
    if 'Int' in column_type:
        parameter = f"--attribute-type={column_name}:int"
        attributes_types.append(parameter)
    elif 'Float' in column_type:
        parameter = f"--attribute-type={column_name}:float"
        attributes_types.append(parameter)   
In [2]:
print(' '.join(attributes_types))
---------------------------------------------------------------------------
NameError                                 Traceback (most recent call last)
Cell In[2], line 1
----> 1 print(' '.join(attributes_types))

NameError: name 'attributes_types' is not defined

Then we edit the metadata for the generated vector tiles to remove the long generator_options

Edit metadata.json and remove generator_options

pmtiles show test.pmtiles --metadata > metadata.json
pmtiles edit test.pmtiles --metadata=metadata.json
In [ ]: