instrumentos:codigos:tuyo_shp
| Ambos lados, revisión anteriorRevisión previaPróxima revisión | Revisión previa | ||
| instrumentos:codigos:tuyo_shp [2022/07/30 20:55] – cherranz | instrumentos:codigos:tuyo_shp [2022/07/30 23:45] (actual) – cherranz | ||
|---|---|---|---|
| Línea 1: | Línea 1: | ||
| ====== Construcción de capa esri shape a partir de datos tuyo ====== | ====== Construcción de capa esri shape a partir de datos tuyo ====== | ||
| < | < | ||
| - | # librerias | + | #funciones |
| - | import sys | + | def epoch(f): |
| - | import fiona | + | |
| - | import pandas as pd | + | return int(((datetime.strptime(f, |
| # definir la capa | # definir la capa | ||
| # campos en el csv alt, | # campos en el csv alt, | ||
| schema = { | schema = { | ||
| ' | ' | ||
| - | ' | + | ' |
| } | } | ||
| pointDf = pd.read_csv(' | pointDf = pd.read_csv(' | ||
| + | |||
| #considerar como valido aquel dato con mas de 3 satelites a la vista | #considerar como valido aquel dato con mas de 3 satelites a la vista | ||
| - | filtro=pointDf[' | + | filtro=pointDf[' |
| - | pointDf_f=pointDf[filtro] | + | pointDf=pointDf[filtro] |
| + | |||
| + | #convertir algunas colunas en string para construir la fecha | ||
| + | pointDf[' | ||
| + | pointDf[' | ||
| + | pointDf[' | ||
| + | pointDf[' | ||
| + | pointDf[' | ||
| + | pointDf[' | ||
| + | pointDf[' | ||
| + | pointDf[' | ||
| + | |||
| + | print(pointDf) | ||
| + | |||
| pointShp = fiona.open(' | pointShp = fiona.open(' | ||
| schema = schema, crs = " | schema = schema, crs = " | ||
| - | #iterar sobre cada fika del dataframe y guardar el registro | + | #iterar sobre cada fila en dataframe y guardar el registro |
| - | for index, row in pointDf_f.iterrows(): | + | for index, row in pointDf.iterrows(): |
| rowDict = { | rowDict = { | ||
| ' | ' | ||
| ' | ' | ||
| - | ' | + | ' |
| } | } | ||
| pointShp.write(rowDict) | pointShp.write(rowDict) | ||
instrumentos/codigos/tuyo_shp.1659225326.txt.gz · Última modificación: 2022/07/30 20:55 por cherranz